Setting up Postfix to relay to another host

  • Edit Below this is the original post, but I solved this issue on my own and have decided to share. YMMV.


    1. Make sure Postfix is running (run netstat -ntlup and see if port 25 says "master" or "sendmail"; if "sendmail" kill it then start Postfix)
    2. Get the SMTP information for the domain you want to relay through (in my case smtp.live.com and port 587).
    3. Log into your server and go to /etc/postfix
    4. Edit the "main.cf" file...
    4a. Comment out "smtpd_sasl_type = dovecot"
    4b. Make sure this is correct: "smtpd_sasl_auth_enable = yes"
    4c. Your SMTP server may not require it, mine does: "smtpd_use_tls = yes" (optional)
    4d. SASL password for authentication: "smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd"
    4e. Used for telling Postfix where to relay mail to: "transport_maps = hash:/etc/postfix/transport"
    4f. Comment out the /etc/postfix/iMSCP/transport option
    5. To create a transport to relay emails to, create/edit "/etc/postfix/transport" by adding a line: "your_domain.com port:[smtp_server]" so in my case it is "domain.com 587:[smtp.live.com]"
    6. Run "postmap /etc/postfix/transport"
    7. If you need SASL authentication create "/etc/postfix/sasl_passwd" and add this: "smtp_server user@your_domain.com:password" so mine looks like "smtp.live.com ehansen@domain.com:the_password"
    8. Run "postmap /etc/postfix/sasl_passwd"
    9. Restart Postfix: "service postfix restart" on Ubuntu


    You can test this by either sending an email through i-MSCP or by any other means. Check your logs and spam as some services will throw it there.
    ------------------------------------------
    Okay so since we cannot specify the SMTP information for i-MSCP to use right now, I'm forced to set up Postfix to basically act as a relay.


    I'm trying to have Postfix send messages from my domain only to smtp.live.com:587.


    Does anyone know how to do this or how to set it up? I'm not very fluent in Postfix so I don't want to break anything and cause even more work for myself.

    Edited once, last by ehansen ().

  • OR simply use a plugin such as:


    http://forum.i-mscp.net/Thread…-MTA-Postfix-as-smarthost


    To resume, you re-invent the wheel and some parts are wrong in your howto. Steps 1, 4a, 4b are useless with i-MSCP.


    Thanks you for using i-MSCP

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

    Edited once, last by Nuxwin ().


  • Well, to be fair you didn't provide me this link in my last thread about the email thing so I figured it wasn't created yet.


    Quote


    To resume, you re-invent the wheel and some parts are wrong in your howto. Steps 1, 4a, 4b are useless with i-MSCP.


    Thanks you for using i-MSCP


    Re: step 1 - Actually it is necessary as most systems install sendmail by default, and if you don't disable it first (which i-MSCP doesn't) then it'll be running and won't allow Postfix to run instead.


    Re: step 4a - Might be pointless but when I did it myself I wanted to remove any trace of external programs (i.e.: dovecote).


    Re: step 4b - Not sure how this is irrelevant for my how-to?


  • Well, to be fair you didn't provide me this link in my last thread about the email thing so I figured it wasn't created yet.


    You are not able to search on the forum before posting? :P



    Re: step 1 - Actually it is necessary as most systems install sendmail by default, and if you don't disable it first (which i-MSCP doesn't) then it'll be running and won't allow Postfix to run instead.


    Only because you are using a vps with a template that install sendmail. It's not the case of most system. ;)



    Re: step 4a - Might be pointless but when I did it myself I wanted to remove any trace of external programs (i.e.: dovecote).


    You are confusing the Dovecot SASL layer, which, allow SMTP authentication with other Dovecot layers.


    When you install i-MSCP, you are asked for the IMAP/POP software to use (courier/dovecot). If you choose Courier, the MTA (Postfix) will use the Cyrus SASL implementation. When choosing dovecot, the MTA (Postfix) will use the Dovecot SASL implementation.


    To resume, if the user have chosen dovecot, the Cyrus SASL will not be installed and because you remove it in your howto, SMTP authentication will not work.


    Thank you for using i-MSCP

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

    Edited once, last by Nuxwin ().

  • You are not able to search on the forum before posting? :P


    But this: "This plugin allow to configure the i-MSCP MTA (Postfix) as smarthost using SASL authentication. It's needed for those that use i-MSCP on personal computer with dynamic IP." does not say "use Postfix as a transport/relay", it says "use Postfix behind a dynamic IP". Two different concepts. ;)


    Also, who's to say I did not search?


    Quote

    Only because you are using a vps with a template that install sendmail. It's not the case of most system. ;)


    I checked against a normal install of Ubuntu LTS and you are right. But still, its nice to cover more than just the majority isn't it, in trying to get people to use software? Its like saying "oh, you use Ubuntu 12.04 instead of 12.10? Too bad."



    Fair enough, thank you. Like I said before I'm not fluent in Postfix so I was just being overly careful.

  • Re;


    But this: "This plugin allow to configure the i-MSCP MTA (Postfix) as smarthost using SASL authentication. It's needed for those that use i-MSCP on personal computer with dynamic IP." does not say "use Postfix as a transport/relay", it says "use Postfix behind a dynamic IP". Two different concepts. ;)


    Also, who's to say I did not search?


    I'll become crazy soon with you...



    :P :P :P


    Do you know what is a smarthost? If you know, you would never said such words. ;)


    Read https://en.wikipedia.org/wiki/Smart_host please



    I checked against a normal install of Ubuntu LTS and you are right. But still, its nice to cover more than just the majority isn't it, in trying to get people to use software? Its like saying "oh, you use Ubuntu 12.04 instead of 12.10? Too bad."


    No more comments there... I cannot lost more time. We cannot cover all exotic cases. i-MSCP development is based on debian/ubuntu as they come by default.


    Thank you for using i-MCP

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

    Edited once, last by Nuxwin ().