I need to send SMTP email out from my home box running Fedora 14, so I can try StatusNet (Laconica microblog). These days email cannot be sent directly out from a residential DSL because it looks like spam. My ISP provides no SMTP relay, but I can use Gmail—thank you, Google. Fedora 14 comes with sendmail, but it is harder to configure than most Linux software. So now here is what I cobbled together from two sites: AppGirl: “Configuring Sendmail to relay through Gmail SMTP” and James Lloyd: “Using Gmail as a Sendmail Relay”. First, open a terminal and run:
su - # login as root yum -y install sendmail-cf # install sendmail cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc.orig # make a backup vi /etc/mail/sendmail.mc # edit configuration
Near the very bottom before MAILER insert the following lines. Sendmail is picky about the quotation marks: when I first pasted them, they were wrong and gave me a syntax error. This section is a combination of the two sources above which fixes the error in /var/log/maillog “no route to host” which apparently has nothing to do with DNS resolution.
define(`SMART_HOST',`smtp.gmail.com')dnl define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')
Then save. Back in the terminal:
mkdir /etc/mail/auth # a place to store credentials vi /etc/mail/auth/client-info # edit credentials file AuthInfo:smtp.gmail.com "U:root" "I:<YOUR GMAIL USERNAME HERE>@gmail.com" "P:<YOU GMAIL PASSWORD HERE>"
Of course, fill out your real login info, save, and exit. The next section skips the part about the openssl certificates: I ran it, but it didn’t seen to be necessary on Fedora.
makemap hash client-info < client-info chmod 700 /etc/mail/auth chmod 600 /etc/mail/auth/* cd /etc/mail make # compile configuration service sendmail restart # read new configuration
Finally, send a test email.
echo 'this is a test'| mail -s test_email firstname.lastname@example.org
If it fails, read /var/log/maillog and /var/log/messages.