This of course is not possible as described in the following KB 2063147
This got me interested to setup a solution that would provide the functionality to allow outgoing email through SMTP relay service in stead of setting up a full fledged local email server.
Here are the steps I took to setup postfix on CentOS to relay outgoing email to 3de party which requires authentication.
- Install and configured a linux operating systems.
- Now we need to install and update the packages required for our configuration which includes postfix as well as cyrus-sasl-plain which is not installed by default on CentOS 6+
- sudo yum install postfix cyrus-sasl cyrus-sasl-plain
- To make postfix the default MTA in our system lets remove sendmail
- sudo yum remove sendmail
- Postfix setup:
- vi /etc/postfix/main.cf
- Configure server FQDN:
- mydomain = <domain.com>
- myhostname = <postfixservername.domain.com>
- Configure relayhost to email provide smtp server. Verify the port since might not be default 25 to prevent spamming.
- relayhost = <yourisp.smtp.com:2525>
- relaydomain = <domain.com>
- Configure cyrus-sasl-plain:
- smtpd_sasl_auth_enable = yes
- smtpd_sasl_path = smtpd
- stmpd_sasl_password_maps = hash:/etc/postfix/sasl_passwd
- smtpd_sasl_type = cyrus
- smtp_sasl_auth_enable = yes
- Configure receive mail so that communication can be established from all networks. If you select inet_interfaces = localhost then can only send from local server.
- inet_interfaces = all
- inet_protocols = all
- Configure additional trust and relay control
- mynetworks_style = subnet (if you want to specify specific network subnets)
- mynetworks_style = host (if you want to specify specific host names)
- mynetworks = 127.0.0.0/8, 192.168.1.0/24
- Now since our SMTP server requires authentication we need to setup username and password.
- vi /etc/postfix/sasl_passwd
- yourisp.smtp.com:2525 username:password
- the servername should match exactly what you have entered for relayhost in /etc/postfix/main.cf
- Generate a postfix lookup table
- postmap hash:/etc/postfix/sasl_passwd
- Test lookup table which should return username and password
- postmap -q yourisp.smtp.com:2525 /etc/postfix/sasl_passwd
- Verify sasl_passwd and sasl_passwd.db files are read/write enabled for root only to protect the plain text password.
- chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
- Add postfix to be started at boot
- chkconfig --add postfix
- start service
- /etc/init.d/postfix start
- Send test email.
- # sendmail -t
- TO: firstname.lastname@example.org
- From: email@example.com
- Subject: Test
- Did you get this email?
If you check the status of service and get error: "Master is Dead ButPid File Exists", verify that you have removed sendmail successfully.
Connection refused when trying to send from vCenter, verify that port 25 is listening on host with # netstat -nlp | grep 25. If it shows with 127.0.0.0/8 then it will only allow local connection. This needs to show 0.0.0.0:25 so make sure you have inet_interfaces = all.
Some useful links: