Can I configure Postfix to send through Postmark?
If you use our SMTP server option, you can use a smarthost in Postfix to relay mail through Postmark. A big advantage of this is that it requires no changes to your application code and the local mail server will queue emails on its own. For instance, in the case there are connection problems to Postmark, the emails will be queued and retried. Here is how to configure the server:
IMPORTANT: Make sure you have SASL authentication package installed first. It can be installed using
apt-get install libsasl2-modules
oryum install cyrus-sasl-plain
. If not, you will see authentication errors like "SASL authentication failed; no mechanism available".
Relay all outgoing emails
Locate and open the /etc/postfix/main.cf
file, then update it with the following settings:
#start postmarkapps settings smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:secret:secret (where "secret is your API token") smtp_sasl_security_options = noanonymous smtp_tls_security_level = may smtp_tls_loglevel = 1 relayhost = [smtp.postmarkapp.com]:25 ##end postmarkapp settings
Relay specific emails
Additionally, if you just want to route emails that contain a specific from address, you can add these settings:
In /etc/postfix/main.cf
:
#start postmarkapps settings sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:secret:secret (where "secret is your API token") smtp_sasl_security_options = noanonymous smtp_tls_security_level = may smtp_tls_loglevel = 1 relayhost = ##end postmarkapp settings
In /etc/postfix/sender_relay
add:
email@yourdomain.com [smtp.postmarkapp.com]:25
To make the change permanent and so Postfix can recognize it, run:
postmap /etc/postfix/sender_relay
Restart Postfix
Once finished either option, you will need to restart Postfix by running:
/etc/rc.d/init.d/postfix restart
Now, any emails sent to your Postfix server will be automatically routed to Postmark.