Saturday, November 29, 2008

Postfix - Relaying mails through a third party server

Here I will describe how to relay emails through a third party server from a Postfix server.

Without SMTP AUTH:

If relaying server does not authenticates while relaying through it, use following. Define "relayhost" parameter in /etc/postfix/mail.cf like follows.

relayhost = smtp.relayhost.com

This will do a MX lookup for smtp.relay.com and then send email to smtp.relayhost.com

relayhost = [ smtp.relayhost.com ]

The square brackets turns off MX lookups of smtp.relay.com and simply resolve its IP address and send the emails.

Save the file and reload postfix.

/etc/init.d/postfix reload


With SMTP AUTH:

Most of the relaying server needs you to authenticate with them for relaying through them. Follow these steps to relay with SMTPAUTH.

Add these settings to /etc/postfix/main.cf

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =

Create a file called /etc/postfix/sasl_passwd which should contain the username and password for relaying. (It will be provided by relay server provider).

smtp.relayhost.com username:password

The password is enterted in cleartext format, make it readably only by root.

chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd

Create the hash file.
postmap /etc/postfix/sasl_passwd

Make the hash file world readable.
chmod 644 /etc/postfix/sasl_passwd.db

Reload the Postfix config.
/etc/init.d/postfix reload

Teseting the results:

Send an email from local postfix to an external user and it should be relayed through smtp.relayhost.com. Check /var/log/maillog for "relay" log. It will log the errors if there are any configuration mistakes.

------------------------------------------------------------------------------------------------------------------

1 comment:

Anonymous said...

ZfoJxz [url=http://nba35.webnode.cn]NBA直播表[/url] DocOrm [url=http://nba36.webnode.cn]新浪NBA直播[/url] SnvUzf [url=http://nba37.webnode.cn]英超赛程表[/url] YhgXaw [url=http://nba38.webnode.cn]NBA直播[/url] WorRkl [url=http://nba39.webnode.cn]天下足球直播[/url] JpbGaz [url=http://nba40.webnode.cn]NBA直播视频直播[/url] JoaYqf [url=http://nba41.webnode.cn]英超宝贝[/url] LzrRux [url=http://nba421.webnode.cn]天下足球直播[/url]
FtpAlc [url=http://nba27.webnode.cn]天下足球直播[/url] TioRun [url=http://nba28.webnode.cn]腾讯NBA直播视频[/url] BkqAtk [url=http://nba29.webnode.cn]新浪体育NBA直播[/url] MnrSgq [url=http://nba30.webnode.cn]NBA直播热火[/url] GaqBth [url=http://nba31.webnode.cn]英超宝贝[/url] HfkYuk [url=http://nba32.webnode.cn]新浪体育NBA直播[/url] WnzYpm [url=http://nba33.webnode.cn]NBA直播吧[/url] YywPiu [url=http://nba34.webnode.cn]风云足球直播[/url]

[url=http://tt2929.com/]全讯网[/url]
MfdYxu [url=http://nba197.webnode.cn]NBA直播吧[/url] PphAew [url=http://nba20.webnode.cn]天下足球直播[/url] RngQac [url=http://nba21.webnode.cn]英超赛程[/url] HroPlt [url=http://nba22.webnode.cn]NBA直播表[/url] ZdfTsy [url=http://nba230.webnode.cn]腾讯NBA直播[/url] NkaZdy [url=http://nba249.webnode.cn]NBA直播湖人[/url] YhiVnt [url=http://nba25.webnode.cn]NBA直播湖人[/url] DncMxj [url=http://nba26.webnode.cn]英超直播[/url]
TfkOjd [url=http://nba115.webnode.cn]英超积分榜[/url]MsvFaa [url=http://nba12.webnode.cn]NBA直播湖人[/url]AmlDsn [url=http://nba13.webnode.cn]风云足球直播[/url]NxpJhy [url=http://nba14.webnode.cn]新浪体育NBA直播[/url]CrgYuu [url=http://nba15.webnode.cn]NBA直播[/url]LwtUyf [url=http://nba16.webnode.cn]风云足球直播[/url]LycSgi [url=http://nba170.webnode.cn]NBA直播[/url]AijFtl [url=http://nba18.webnode.cn]英超宝贝[/url]
[url=http://tt5252.com/]博彩通[/url]