Postfix & webapp set but mails not delivered (except if sent in ssh)

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

  1. Keoz

    Keoz Member


    I desperately need help... !

    I wish I may use a relay mail server (Mailgun) for :

    E-mai domain, e.g. ““
    A webapp to send email verification messages to new account creators (issue case below)
    An upcoming E-mail marketing project

    /// ISSUE ///
    Despite all configuration steps below were achieved (Mailgun, OVH, ISPConfig)
    , and that test to send email from terminal has worked fine (delivery OK), I can’t get a chosen webapp delivering email verification messages to new account creators, although a notification popup says that message was sent !

    So first of all, this is how the webapp is set to send email using my Mailgun SMTP credentials :

    Mailer : PHP Mail (default)
    SMTP Host :
    SMTP Port : 587
    SMTP Username : [email protected]
    SMTP Password : randompassword
    From Email (e.g) : [email protected]
    SMTP Authentication : 1
    Message is note delivered whatever the port is set to : 25, 587, 465

    • Existing domain name, e.g. ““ and related MX plan at hosting provider (OVH)
    • Account created, domain name added, and SMPT credentials generated in Mailgun (relay mail server)
    • Auth protocole keys (SPF and DKIM) generated in Mailgun account, recopied as TXT records at OVH (hosting provider), and successfully verified in Mailgun afterward.
    • E-mail domain set and activated in ISPConfig panel (under E-mail tab in main menu)
    • DKIM not enabled in ISPConfig, because generated in Mailgun and already enabled at OVH (hosting provider)
    • Postfix configured in ISPConfig, with SMTP credentials for routing outgoing mail to Mailgun (relay mail server) : system/server configuration/E-mail

    /// ISSUE TRACKING ??? ///
    When email sending test is made from command line mail -s "Test maill" [email protected] <<< "A test message using Mailgun", the recipient sees “root“ in place of the sender’s email address. I presume the address behind “root“ is “[email protected]“.

    As message sent from the webapp are not delivered, I wonder if it’s because :
    • The sender should no be default “[email protected] (from Mailgun default SMTP credentials)
    • There are conflicts generated because of configurations that are maybe not required (e.g : E-mail domain in ISPConfig) ?
    • Postfix configuration in ISPConfig requires more than Mailgun SMTP credentials settings….
    Please help !

  2. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    It looks like your web app is sending via smtp, so should be unrelated to having the domain in ispconfig or what your postfix settings are (you're not using either).

    Try adding some debugging to your web app and see if it is sending successfully it failing. If it's sending, you might need to see what tools mailgun gives you to see delivery status, and if it is also delivering to a remote server, follow up with that server's admin to see what happened.
  3. Keoz

    Keoz Member

    So can I roll-back changes made in ISPConfig without any worry : meaning to remove E-mail domain and take Postfix back to its default configuration settings. Is this what you mean ?

    I ask this question because
    surfing the web I have read that PHP Mail (default option for the web app smtp settings) requires Postfix to be running, e.g. :

    I will have a look to what Mailgun tools may reveal…
    But I don’t have enough understanding of what it means or how to proceed to add a debug to a web app…..

    • For now, the web app has only one registered user that is default admin user, could this mean that he is the default sender of email verification messages sent to new subscribers ?
    • If yes, should the web app admin user's email address and password be set in the web app smtp settings, instead of default ones collected from Mailgun (as in first post above) ?
    • If yes, should I create a Mailbox in ISPConfig with same credentials the web app requires from admin user (myself) to access and manage it, so that his email address may benefit from spf and dkim autentification protocoles ?
    Last edited: May 1, 2021
  4. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    I simply mean that if your web app is sending mail through mailgun directly via smtp, it is not using postfix or any configuration from ispconfig.

    I don't know what you should setup in ispconfig offhand, it depends if you want to host email for the domain, etc. If you just want to send via an external mail service, you might not need to do any local setup.
  5. Keoz

    Keoz Member

    Sending logs are displayed
    and accessible from my Mailgun account only if Postfix is configured with my Mailgun SMTP credentials, otherwise logs are not displayed ! I also found a tutorial that combines Mailgun and Postfix :

    For now, e-mail is accepted (log1) and delivered to recipient (log2) when sent from ssh command line such as:
    mail -s "Test mail" [email protected] <<< "A test message using Mailgun ».

    When the sending of account verification’s message is triggered upon member account request, despite the web app e-mail sending module was configured and saved with same Mailgun SMTP credentials as set in Postfix, e-mail is accepted (log1), but NOT delivered to recipient, or rejected as SPAM (log2), .

    Does it make any sens to think that I would get rid of the failure if my MX records were in ISP Config, rather than on side of my hosting provider ?
    Last edited: May 2, 2021
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    MX records have to be on the DNS server that is responsible for this zone, it does not matter if that's your ISPConfig system or the DNS server of your provider.
  7. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    So if you send with postfix and everything works, and also shows logs in mailgun, but your webapp neither sends nor does anything show in mailgun logs, the problem would seem to be in your web app. Continue debugging that.
    What gives you an indication that the mail was accepted? You said mailgun logs didn't show anything, which seems to be an indication that it was not.
  8. Keoz

    Keoz Member

    Mailgun displays two infos sets per log, the first one probably notifies that conditions are or not met for Mailgun to relay an email, and the second one notifies about the delivery final status.

    You are probably right, and maybe that replies to question n°3 and 4 on this new post (Postfix as null client server) will help me to configure the web app appropriately :


Share This Page