Have an app that sends Email and runs on Google Compute Engine (GCE)? Can’t use a locally installed mail server to send emails because Google is blocking sending Emails through the GCE infrastructure?
The solution is simple. Use a 3rd party Email service such asĀ Mandrill, Mailgun, Sendgrid, etc.
Don’t want to change your code and still use a locally installed mail server to forward emails but it doesn’t work?
The solution is simple:
- Install postfix
- Configure postfix to forward using port 2525
- Make sure to enable SASL authentication if the Email service you are using supports it (most do)
I have a server running Celery and I wanted to configure it to send Emails on errors. Celery can only work with a regular SMTP server so I had to install a local one and make sure I forward it to Mandrill, our Email service of choice.
I configured it to forward to smtp.mandrillapp.com port 2525 and configured sasl authentication with our username and password.
# enable SASL authentication smtp_sasl_auth_enable = yes # tell Postfix where the credentials are stored smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous # use STARTTLS for encryption smtp_use_tls = yes relayhost = [smtp.mandrillapp.com]:2525
Works like a charm!