One of the main benefits of sympathetic pregnancy insomnia is that I am able to get a jump on all these little projects that I had been meaning to take care of but never had the motivation. Configuring sendmail to use Yahoo Mail as a relay to handle outbound mail from Apache is one of those projects I’ve put off for far to long. Thanks to two HowTos I managed to knock this out in a couple of minutes.
sudo apt-get install sendmail
sudo /etc/init.d/sendmail stop
sudo nano /etc/mail/authinfo and add the following:
AuthInfo:yahoo.com “U:babydaddy@your_ATT_Domain” “I:babydaddy@your_ATT_Domain” “P:password_here” “M:PLAIN”
AuthInfo: “U:babydaddy@your_ATT_Domain” “I:babydaddy@your_ATT_Domain” “P:password_here” “M:PLAIN”
sudo chmod 660 /etc/mail/authinfo to lock it down.
sudo makemap hash /etc/mail/authinfo < /etc/mail/authinfo to make the map file.
sudo nano /etc/mail/sendmail.mc and look for or add the following lines:
define(`confAUTH_OPTIONS’, `A’)dnl
define(`confAUTH_MECHANISMS’, `LOGIN PLAIN DIGEST-MD5 CRAM-MD5′)dnl
TRUST_AUTH_MECH(`LOGIN PLAIN DIGEST-MD5 CRAM-MD5′)dnl
FEATURE(`authinfo’,`hash -o /etc/mail/authinfo.db’)dnl
define(`SMART_HOST’, `esmtp:[smtp.sbcglobal.yahoo.com]‘)dnl
sudo cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.bak because you can never to too sure.
sudo make /etc/mail/sendmail.cf -C /etc/mail to rebuild your sendmail.cf.
sudo /etc/init.d/sendmail start
To test your set up create a text file that at least includes a To and a Subject:To:ServerMonkey@foo
Subject:Linux Rules Windows Drools
sudo sendmail -Am -v -t < your_text_file to shoot a copy out to yourself.
You should see something like this:
babydaddy@your_ATT_Domain… Connecting to smtp.sbc.mail.yahoo4.akadns.net. via esmtp…
220 smtp110.sbc.mail.re2.yahoo.com ESMTP
>>> EHLO your_domain
250-smtp110.sbc.mail.re2.yahoo.com
250-AUTH LOGIN PLAIN XYMCOOKIE
250-PIPELINING
250 8BITMIME
>>> AUTH PLAIN xxxxxxxxxxxxxxxxxxxxxxxx
235 ok, go ahead (#2.0.0)
>>> MAIL From: AUTH=root@your_domain
250 ok
>>> RCPT To:
>>> DATA
250 ok
354 go ahead
>>> .
250 ok 1166057377 qp 49511
babydaddy@your_ATT_Domain… Sent (ok 1166057377 qp 49511)
Closing connection to smtp.sbc.mail.yahoo4.akadns.net.
>>> QUIT
221 smtp110.sbc.mail.re2.yahoo.com
sudo nano /etc/php5/apache2/php.ini so that it knows where sendmail hangs out.
Find the line with sendmail_path, delete the ; and edit it to read:
sendmail_path = /usr/sbin/sendmail -i -t
sudo /etc/init.d/apache2 reload to make the changes stick.
Sendmail is now configured to use Yahoo as a relay! Now, ideally you should be able to massage this to use any external SMTP server that allows plain text authentication.
Gratefully cribbed from here and here.
Comments
James, Dale
james, Mike
james, Mike, james [...]
james, Mike
james, Mike
james, Kyle Daigle