Postfix - relay trough other smtp server with email authorization
Posted by valqk on
To relay our mail from a home/office server trough real mail server, that has all needed stuff like PTR, SPF, DKIM etc. stuff setup, the easies way is to 'login' to a free, open service like gmail, yahoo etc. server and send from our account there.
So, let's do this with postfix.
The EASY way to do is, if the provider supports submission protocol (port 587).
Then in main.cf we set a relayhost
then we create /etc/postfix/sasl_passwd:
we create hash file:
#> postmap /etc/postfix/sasl_passwd
then we make:
#> chmod 400 /etc/postfix/sasl_passwd*
and then
#> /etc/init.d/postfix restart
OR
#> systemctl restart postfix (8 and above)
The HARD way is to do it with stunnel program.
We should do this ONLY if provider supports only ssl smtp connection.
Make sure stunnel is installed:
#> apt-get install stunnel4
First, make same steps as above BUT relayhost is with other valie:
then in /etc/postfix/main.cf check
After setting relay to localhost at random port, we setup stunnel.
We create /etc/stunnel/mail.server.com.conf
It holds this:
Then, we restart stunnel and postfix and we are ready.
So, let's do this with postfix.
The EASY way to do is, if the provider supports submission protocol (port 587).
Then in main.cf we set a relayhost
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
then we create /etc/postfix/sasl_passwd:
[smtp.gmail.com]:587 USERNAME@gmail.com:PASSWORD
we create hash file:
#> postmap /etc/postfix/sasl_passwd
then we make:
#> chmod 400 /etc/postfix/sasl_passwd*
and then
#> /etc/init.d/postfix restart
OR
#> systemctl restart postfix (8 and above)
The HARD way is to do it with stunnel program.
We should do this ONLY if provider supports only ssl smtp connection.
Make sure stunnel is installed:
#> apt-get install stunnel4
First, make same steps as above BUT relayhost is with other valie:
then in /etc/postfix/main.cf check
relayhost = 127.0.0.1:10465
After setting relay to localhost at random port, we setup stunnel.
We create /etc/stunnel/mail.server.com.conf
It holds this:
client = yes
chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /stunnel4.pid
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
[ssmtp]
accept = 127.0.0.1:10465
connect = mail.hostit.bg:465
Then, we restart stunnel and postfix and we are ready.
Trackbacks
Trackback specific URI for this entryThis link is not meant to be clicked. It contains the trackback URI for this entry. You can use this URI to send ping- & trackbacks from your own blog to this entry. To copy the link, right click and select "Copy Shortcut" in Internet Explorer or "Copy Link Location" in Mozilla.
No Trackbacks
Comments
Display comments as Linear | ThreadedNo comments