Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    PfSense - How Mail to multiple recipients via shell and via gui

    Scheduled Pinned Locked Moved General pfSense Questions
    2 Posts 1 Posters 2.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      javcasta
      last edited by

      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/

      Javier Castañón
      Técnico de comunicaciones, soporte y sistemas.

      Mi web: https://javcasta.com/

      Soporte scripting/pfSense https://javcasta.com/soporte/

      1 Reply Last reply Reply Quote 0
      • J
        javcasta
        last edited by

        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.

        Javier Castañón
        Técnico de comunicaciones, soporte y sistemas.

        Mi web: https://javcasta.com/

        Soporte scripting/pfSense https://javcasta.com/soporte/

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.