I’m using Ubuntu and set postfix up to use gmail as a relay to send mail following this guide. I can send emails fine but I would like to receive emails and run a script like this. Is it possible to receive emails from my relay and then run a bash script?
Advertisement
Answer
We figured it out using fetchmail to grab the emails and then procmail to run a script.
/root/.fetchmailrc
# set username set postmaster "root" # set polling time (5 minutes) set daemon 600 poll pop.gmail.com with proto POP3 user 'username@gmail.com' there with password 'password' is root here options ssl mda "/usr/bin/procmail -m /etc/procmail/procmail.conf";
/etc/procmail/procmail.conf
CORRECTHOME=/root MAILDIR=$CORRECTHOME/ LOGFILE=/var/log/procmail/log VERBOSE=on :0 | /root/procmail/script_to_run.sh