So, you're a developer testing lots of codes and you want to ensure that you don't accidentally send out email to people during testing.
However, you also want to actually view emails in a real email client, not a console.
This is how you can do it using Ubuntu and Exim ensuring that the email gets sent out through Google apps.
sudo apt-get install exim4
Turn on 2-Step Authentication in Google Apps and create a two step pass code - we're going to need this later so write it down. See Two-Step Authentication for more details.
Copy
update-exim4.conf.conf
to/etc/exim4/update-exim4.conf.conf
(yes....conf.conf
)Run the following:
sudo HOSTNAME=`hostname` sed --in-place -e "s/\[YOUR-HOST-NAME\]/$HOSTNAME/g" /etc/exim4/update-exim4.conf.conf
Copy passwd.client to /etc/exim4/passwd.client then;
Replace
[email protected]
with your username and domain name.Replace
2steppassword
with the 2-Step password you created in Step 1.Change access to the file;
sudo chown root:Debian-exim /etc/exim4/passwd sudo chmod 640 /etc/exim4/passwd
Copy
01_exim4-config_catchall_redirect
into/etc/exim4/conf.d/router/01_exim4-config_catchall_redirect
and change it accordingly.Update and Restart;
sudo update-exim4.conf sudo service exim4 restart
echo "Hello World" | mail -s 'Subject...' [email protected]
Rather than the mail above being delivered to [email protected]
it will be delivered to the address you specified in 01_exim4-config_catchall_redirect
.
If the mail doesn't get there you can monitor the exim logs as follows;
tail -f /var/log/exim4/mainlog
Depending on how your Google Apps has been configured you may not need to use a Two-Step Authentication pass code. However if you don't you'll need to store your actual password, unencrypted, on the file system - not a very smart idea.
So, to save a whole bunch of stuffing around just turn it on :)