PfSense - How Mail to multiple recipients via shell and via gui
-
Hello.
A small contribution, I just test in pfSense 2.3.1
How Mail to multiple recipients via shell:
For scripting, sometimes I miss send mail to multiple recipients from a pfSense shell.
For example if I want the output of a command is sent, not only to email defined in System> Advanced> Notifications > E-Mail
Simply by editing the file "/etc/inc/notices.inc" and the line 360 which is
$to = $config['notifications']['smtp']['notifyemailaddress'];
Add:
$to = $config['notifications']['smtp']['notifyemailaddress']; $to = $to . ',' . "somebody-more-1@server.com"; $to = $to . ',' . "somebody-more-2-2@otherserver.com";
Where I add two more email recipients.
Save and test from shell with:
echo "multiple recipients" | mail.php -s"test multiple"
Regards.
Ref: https://www.javcasta.com/pfsense-enviar-mail-a-multiples-destinatarios-via-shell/
-
Hello.
How Mail to multiple recipients, not only via shell
https://forum.pfsense.org/index.php?topic=112360.msg625732#msg625732
System > Advanced > Notifications > E-Mail > Notification E-Mail address: set recipients with coma separator.
destinatario1@servidor.com,destinatario2@servidor2.com,destinatario3@servidor3.com
Save. And Edit file “/etc/inc/notices.inc” (about line 360), add:
$to = $config['notifications']['smtp']['notifyemailaddress']; //Multiple recipientes $to = preg_split("/[\s,]*(\,|\;|\:)[\s]*/", $to); $to = implode(",",$to);
Save and test:
root# echo "multiple recipients" | mail.php -s"test multiple"
At log:
May 24 14:21:46 php-cgi mail.php: Message sent to javier@javcasta.com,alguien-mas1@gmail.com,alguien-mas-2@gmail.com OK
Note: (via: http://ehealth-aussie.blogspot.com/2013/07/pfsense-e-mail-alerts-sent-to-multiple.html )
For package Email-report, change in file “/etc/inc/mail_reports.inc”
$address = $config['notifications']['smtp']['notifyemailaddress']; /* New lines start here */ $addr_array = preg_split("/[\s,]*(\,|\;|\:)[\s]*/", $address); foreach($addr_array as $addr){ $mail->AddAddress($addr, "Report Recipient ".($addr_count++)); } /* New lines end here */ /* Comment out the line below */ //$mail->AddAddress($address, "Report Recipient"); $mail->Subject = "{$config['system']['hostname']}.{$config['system']['domain']} Email Report: {$headertext}";
Regards.