Config postfix smarthost » Historie » Revision 1
Revision 1/2
| Weiter »
Jeremias Keihsler, 13.01.2017 09:36
Setting up Postfix to send mails via external mail-account¶
Preliminary note¶
See also:- https://www.zulius.com/how-to/set-up-postfix-with-a-remote-smtp-relay-host/
- http://rs20.mine.nu/w/2011/07/gmail-as-relay-host-in-postfix/
A typical email scenario: you're a developer, and you've got a development Linux box at home. You need to be able to send emails from your code or cron jobs, but you're too lazy to set up a full fledged email server on your LAN. Or you just want to use an email account provided by Google Apps, Yahoo, your ISP or in our case a iRedMail-installation.
Install postfix¶
Should be preinstalled, as it is the default mail-handler with CentOS
configure postfix¶
myorigin = example.com # 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 80 relayhost = mail.example.com:587 smtpd_sasl_auth_enable = yes smtpd_sasl_path = smtpd smtp_use_tls = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_type = cyrus smtp_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 text smtp_sasl_security_options = noanonymous canonical_maps = hash:/etc/postfix/canonical
additionally we need to know the server and email-address as well as the password to use
The above server hostname and port must exactly match the value for "relayhost" in /etc/postfix/main.cf.
Generate a postfix lookup table from the previous file
Test the lookup table, if all is good then the following will return the specified username:password
next is to bind the local username to the email-address. You may also have a look into /etc/aliases and check who's mail are sent to whom.
The above email-address must exactly match the email-address in sasl_passwd.
Generate a postfix lookup table from the previous file
Make sure that sasl_passwd and sasl_passwd.db files are readable/writeable only by root
Add postfix to be started at boot
Test postfix¶
Fire up Postfix
Test it out using sendmail alias from the command prompt
Von Jeremias Keihsler vor fast 10 Jahren aktualisiert · 2 Revisionen