If you need to install Postfix and use it as a SMTP relay, you can follow these steps below:
Install Postfix and cyrus-sasl with your application manager of choice. If you're compiling from source, be sure to make Postfix with the -DUSE_SASL_AUTH flag for SASL support and -DUSE_TLS for TLS support.
$ yum install postfix cyrus-sasl$ /etc/init.d/sendmail stop$ chkconfig --del sendmailEdit /etc/postfix/main.cf
# Set this to your server's fully qualified domain name.# If you don't have a internet domain name,# use the default or your email addy's domain - it'll keep# postfix from generating warnings all the time in the logsmydomain = local.domainmyhostname = host.local.domain# Set this to your email provider's smtp server.# A lot of ISP's (ie. Cox) block the default port 25# for home users to prevent spamming. So we'll use port 80relayhost = yourisp.smtp.servername:80smtpd_sasl_auth_enable = yessmtpd_sasl_path = smtpdsmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdsmtp_sasl_type = cyrussmtp_sasl_auth_enable = yes# optional: necessary if email provider uses load balancing and# forwards emails to another smtp server# for delivery (ie: smtp.yahoo.com --> smtp.phx.1.yahoo.com)smtp_cname_overrides_servername = no# optional: necessary if email provider# requires passwords sent in clear textsmtp_sasl_security_options = noanonymousAdd the following line to /etc/postfix/sasl_passwd
yourisp.smtp.servername:80 username:passwordGenerate a postfix lookup table from the previous file
$ postmap hash:/etc/postfix/sasl_passwd$ postmap -q yourisp.smtp.servername:80 /etc/postfix/sasl_passwd$ chmod 600 /etc/postfix/sasl_passwd$ chmod 600 /etc/postfix/sasl_passwd.db$ chkconfig --add postfix$ /etc/init.d/postfix start$ sendmail email@example.comPostfix is good to go.
--The Below Steps are specifics. Please ignore if nor required.--If you're attempting to relay mail using Gmail, then it will be necessary to use TLS with Postfix. You'll have to point Postfix at your server's trusted CA root certificate bundle. If that is the case then read below or else ignore.
First, double-check that Postfix was configured with SSL support (ie. ldd should return at least one line starting with libssl):
$ whereis -b postfixpostfix: /usr/sbin/postfix /etc/postfix /usr/libexec/postfix$ ldd /usr/sbin/postfix...libssl.so.6 => /lib/libssl.so.6 (0x00111000)...$ locate ca-bundle.crt/etc/pki/tls/certs/ca-bundle.crtrelayhost = smtp.gmail.com:587# your FQDN, or default value belowmydomain = local.domain# your local machine name, or default value belowmyhostname = host.local.domainmyorigin = $myhostname# SASLsmtpd_sasl_path = smtpdsmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdsmtp_sasl_type = cyrussmtp_sasl_auth_enable = yessmtp_sasl_security_options = noanonymous# TLSsmtp_sasl_tls_security_options = noanonymoussmtp_use_tls = yessmtp_tls_CAfile = /path/to/your/ca-bundle.crtsmtp_sasl_tls_security_options = noanonymoussmtp.gmail.com:587 username:password$ postmap hash:/etc/postfix/sasl_passwd$ chmod 600 /etc/postfix/sasl_passwd$ chmod 600 /etc/postfix/sasl_passwd.db$ postfix reload$ sendmail email@example.comTest relay thru Gmail
If you need to do some debugging please read below or ignore:Monitor postfix mail log in a separate session with the following command
$ tail -f /var/log/maillog(Authentication failed: cannot SASL authenticate to server ...: no mechanism available)smtp_sasl_security_options = noanonymous553 Sorry, that domain isn't in my list of allowed rcpthosts. (in reply to RCPT TO command)
Very nice article, totally what I wanted to find.
ReplyDeleteHello, I read your blog regularly. Your wruting style is awesome, keep it up!
ReplyDelete