If you use our SMTP server option, you can use a smarthost in Sendmail 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.
Follow the Sendmail configuration steps below to relay SMTP emails through Postmark.
Red Hat Enterprise Linux:
yum install sendmail sendmail-cf
apt-get install sendmail sendmail-cf
Add your FQDN (fully qualified domain name) to /etc/mail/local-host-names:
hostname -f >> /etc/mail/local-host-names
Ensure that are able to ping your FQDN by performing the following:
ping $(hostname -f)
Append the following to /etc/mail/sendmail.mc, replace API token with your API token.
AuthInfo:smtp.postmarkapp.com "U:APItoken" "P:APItoken" "M:PLAIN"
echo "AuthInfo:smtp.postmarkapp.com "U:APItoken" "P:APItoken" "M:PLAIN"" >> /etc/mail/access
Add, or modify, the following lines to /etc/sendmail.mc:
define('SMART_HOST', 'smtp.postmarkapp.com')dnl FEATURE('access_db')dnl define('RELAY_MAILER_ARGS', 'TCP $h 25')dnl define('ESMTP_MAILER_ARGS', 'TCP $h 25')dnl
Perform the following to create the Sendmail and access configurations.
cd /etc/mail ; m4 sendmail.mc >sendmail.cf ; makemap hash access <access
The following will send an e-mail from the command line:
echo "testing" > testing.txt ; mail -s "testing" email@example.com < testing.txt ; rm testing.txt
Generally, any configuration problems will be highlighted in the mail log (/var/log/maillog).