My business web site is at www.tombrennansoftware.com and is hosted by Godaddy. Email is setup there for email@example.com, as part of the package. I use Thunderbird as an email client on my Windows PC, and (like I assume most ISP’s) I have port 25 blocked so it is not possible for me to send email out directly to Godaddy. However, Godaddy opens port 80 (among others) with SMTP protocol so that users can bypass ISP restrictions.
So I would like to be able to send email out from the Linux box, and have the Linux mail service use smtpout.secureserver.net port 80, just like I do with Thunderbird on my PC. Here’s what I did to set that up, after a bit of struggling:
- Postfix was already installed and running from the CentOS Linux “minimal” installation, which was kind of unexpected. I say unexpected because even commands such as telnet and man were not included with that basic install.
- This package was required, and I’m not sure why:
yum install cyrus-sasl-plain
- These lines were added to /etc/postfix/main.cf
mydomain = mildredbrennan.com myhostname = mildredbrennan.com relayhost = [smtpout.secureserver.net]:80 smtpd_sasl_path = smtpd smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_type = cyrus smtp_sasl_auth_enable = yes smtp_cname_overrides_servername = no smtp_sasl_security_options = noanonymous
Basically, the configuration parameters above set the relay to the Godaddy server, and the other items specify where and how to find the userid and password for that service.
- Created file /etc/postfix/sasl_passwd with the following line:
- Hashed the passwd entry into a protected /etc/postfix/sasl_passwd.db file with these commands:
cd /etc/postfix postmap hash:/etc/postfix/sasl_passwd chmod 600 /etc/postfix/sasl_passwd chmod 600 /etc/postfix/sasl_passwd.db
- Restarted postfix with a clean maillog
postfix stop > /var/log/maillog postfix start
- Tested outgoing mail successfully – hey it works, I received the email
sendmail firstname.lastname@example.org This is a test .
- But the email has no subject, and I don’t know how to use the sendmail command. Let’s install mailx which I do know how to use:
yum install mailx
- Tested outgoing mail using mailx – success!
mailx -s "This is a subject" email@example.com This is a test message This is the end . EOT
- My goal is to get the mail function to work in php, but that still fails with some kind of /var/spool/postfix permission error, even if the directory is set to 777. A quick google shows this error is an SELinux problem, which can be solved by setting an SE bit:
setsebool -P httpd_can_sendmail 1
And now email out is working for both the mailx command and php mail() processing. Pretty cool I think. Mostly thanks to the doc at this web page. Thank you Mr. White.