Postfix as null client to route outgoing mails to relayhost ?

Discussion in 'Installation/Configuration' started by Keoz, May 10, 2021.

  1. Keoz

    Keoz Member

    Hi,

    To avoid server resources consuming, to avoid sent emails to be detected as spam…, to improve emails deliverability and monitoring, many tutorials found on the web recommend not to send email from self-hosted mail server (Postfix), but to configure it as null client so it routes outgoing emails to a relayhost (relay mail sever) whose owner/user may handle email sending strategy a more secure and resilient way. OS on my VPS is ubuntu 18.04 unlike the one in this related info page.

    In my use case, outgoing emails are generated from a web app that is running on the same VPS where my ISP Config instance, and therefore my Postfix mail server are installed. The web app generates email verification’s messages on individual subscription request, and various notifications message to registered users.

    As a preamble to my questions, let’s assume that :
    • Internet domain name is “tamery.com"
    • VPS hostname have to be changed from default e.g “vps67ZE38.ovh.net" to FDQN “hostname.tamery.com" using “dpkg-reconfigure postfix“ command line
    • relay mail server “smtp.tamery.com“ is configured (from my Mailgun account) and has all appropriated DNS settings verified (TXT, MX, CNAME)
    • relay mail server smtp credentials were set in Postfix, using ISP Config panel

    /// Q1 x2 ///
    May someone please make a feedback and tell if this configuration schema is or not functional ?
    Setting the relayhost can be done both these ways
    , from command line “dpkg-reconfigure postfix“ or from ISP Config panel, what is or not recommended to do ?

    /// Q2 x2 ///
    Assuming that other web apps already running have been requiring the server default hostname entry in their settings to get activated, may they bug or get broken if the hostname is changed as pointed above ?
    Has someone ever experimented changing a machine hostname, and what caution should this be taken when doing so ?

    /// Q3 x3 ///
    The web app configuration module dedicated to mailing allows to choose PHP mail() as the mailer :
    Does ISP Config comes with PHP mail() as default mailler for Postfix ?
    Should I set something in Postfix to get PHP mail() activated ?
    Does “Mailutils“ requires PHP mail() activation so mail sending test can work

    /// Q4 x2 ///
    Unless I am mistaking (please let me know), outgoing parameters to be set in the web app configuration module, should match those used for the null client configuration (Postfix server) and not those on side of Mailgun (relay mail server). But what would my Postfix credentials be then ?
    What port would you recommend, and what should SMTP Authentication parameter be set to in such my use case here ?

    Mailer : PHP Mail (default)
    SMTP Host : hostname.tamery.com
    SMTP Port : ???
    SMTP Username : ???
    SMTP Password : ???
    From Email (e.g) : user.tamery.com
    SMTP Authentication (0,1) : ???

    Regards,
     
  2. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    The postfix package does not set the your hostname (it can set the mailname, which is used in the EHLO command and mail headers).
    For what it's worth, I'm not familiar with mailgun, and don't know what this implies to set a relay server in your mailgun account.
    Using external mail services is a workable solution for some issues; I have no idea if your specific configuration will work for you.
    They probably set the same main.cf setting, and as such if the server were configured as a mail server in ISPConfig, you would use the ISPConfig interface to set it, otherwise you might later save the server config, which has an empty value, and overwrite the custom value you had setup; but you indicated you were setting this up as a null client, in which case 100% of postfix config will be done manually, not via the ISPConfig ui.
    As mentioned, the above command does not change the server's hostname, but whether changing the hostname affects your webapps or not depends on how they're configured, eg. if you were using a hostname in your webapp which is no longer resolvable after changing the server's hostname, then of course the webapp won't be able to connect to that old name anymore to send mail.
    There is no concept of a default php mailer for postfix. PHP has a mail() function which by default is available to be used by any app which calls it, and it uses the system sendmail binary to inject mail into the local queue. You can change the command which is run from mail(), and your webapp could be written to send mail in various other ways.
    It works without changing anything.
    The mailutils package is not required for php mail() to function, nor is it used by mail();
    For the most part, noone knows what your webapp should use (mail() vs. smtp), or the specific settings you need (consult mailgun docs). If you have postfix sending mail out via mailgun already, then you should be able to have your webapp use the same settings and it would work, or use mail() to send mail via postfix and that would also work.
     

Share This Page