Postfix - relay trough other smtp server with email authorization

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 we set a relayhost

relayhost = []: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:


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
#> 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/ check

relayhost =

After setting relay to localhost at random port, we setup stunnel.
We create /etc/stunnel/
It holds this:

client = yes
chroot = /var/lib/stunnel4/
setuid = stunnel4
setgid = stunnel4
pid = /
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1

accept =
connect =

Then, we restart stunnel and postfix and we are ready.


Trackback specific URI for this entry

This 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


Display comments as Linear | Threaded

No comments

Add Comment

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.