Email Relaying Through Sendgrid

From Wiki
Revision as of 12:26, 25 March 2013 by Stocksy (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Email Relaying Through Sendgrid

Install postfix

apt-get update ; apt-get install postfix

vi /etc/postfix/sasl-passwords

[smtp.sendgrid.net]:587 karen@example.com:password

vi /etc/postfix/main.cf

	relayhost = [smtp.sendgrid.net]:587
	smtp_sasl_auth_enable = yes
	smtp_sasl_password_maps = hash:/etc/postfix/sasl-passwords
	smtp_sasl_mechanism_filter = plain, login
	smtp_sasl_security_options =

build your passwords file

cd /etc/postfix
postmap sasl-passwords

apply the config

service postfix restart

Some helpful testing/troubleshooting commands:

sudo tail -f /var/log/mail.log 
echo "test" | mail -s test1 karen@example.com
sudo tcpdump -i eth0 -n -A port submission

Note, 'submission' is ports 465 or 587

Queue Management

delete a message from mailq, using the id

sudo postsuper -d 7729F24436

re-queue all messages

sudo postsuper -r ALL

flush the queue (save waiting)

sudo postqueue -f

Proxy Addresses

These are IP addresses that postfix uses but are not assigned to any interface on the server (eg an external ip address that is being NAT translated). You tell postfix about them to avoid mail loops.

vi /etc/postfix/main.cf

proxy_interfaces = 192.0.2.1

Restart postfix

service postfix restart