Send mail to group via script

Using the EME backend, you can send emails to groups of people. However, there’s now also the option of doing this via your favorite mail client, via a commandline script that EME provides (called “cli_mail.php”). For this to work, you need to be able to pipe emails to scripts, and below I’ll explain how it (can) works for Postfix as mailserver:

  1. in /etc/postfix/transport, add your email you want to forward to the group and a custom postfix transport. E.g.:
    mygroupemail@mydomain.com my-custom-transport:
  2. After that, compile the file (postmap /etc/postfix/transport)
  3. Define that custom transport in /etc/postfix/master.cf:
    my-custom-transport unix – n n – – pipe
    flags=DRhu user=www-data argv=/usr/bin/php -q /path/to/wp-content/plugins/events-made-easy/cli_mail.php -d ${recipient}
  4. reload postfix (postfix reload)

For all options available to cli_mail.php, do “/usr/bin/php -q /path/to/wp-content/plugins/events-made-easy/cli_mail.php -h”
(-f ${sender} and -d {$recipient} are typically used for postfix piping, but you can use other options too)

You can use (as in the example above) “-d <email>” as destination, after which EME will search all defined groups for that email address (there’s an option when editing a group to specify this email address). You can also use “–groupid=<groupid>” as destination (and then you don’t need to specify this email in your group).

Scroll to Top