PHP Mail vs PHPMailer settings from webapp admin panel ?

Discussion in 'Plugins/Modules/Addons' started by Keoz, Apr 12, 2021.

  1. Keoz

    Keoz Member

    Hosting provider : OVH
    Machine : remote VPS 2vCore
    OS distro : Ubuntu 18.04 (bionic beaver)
    User : root with sudo permissions
    Web server : apache 2.4
    Cpanel : ISPConfig 3.2.2


    just installed a new webapp that requires settings (from admin panel) to automatically send :
    • verification e-mail to users creating accounts
    • email notification to admin when users publishes content
    • email notification to users receiving comments
    In purpose to test both available PHP Mail and PHPMailer setting options, I have been creating new accounts (email, password and captcha) with different email addresses, but email sending failed as resumed below, despite I verified the my DNS servers are pointing to my VPS IP address.

    Relating my help request, I also need developers’s word upon this informations found after surfing the web a whole day :
    • if the webapp is not designed to receive email, but only to send plain text email, so PHP Mail (default) is sufficient !
    • choosing PHPMailer instead of PHP Mail requires some SPF, DKIM, DMARC further settings (and propagation time) to avoid sent emails being blocked or spamed !
    • It seems that my hosting provider (OVH) never did, and still not handle DKIM settings in DNS zones for MX plan subscribers….


    *** With PHP Mail ***
    Mailer : PHP Mail (default)
    SMTP Host : localhost
    SMTP Port : 25
    SMTP Usename : [email protected]
    SMTP Password : my password
    From Email : [email protected]
    SMTP Authentication [0 or 1] : 1
    Results for email verification message delivery
    [email protected] (delivered)
    [email protected] (failed)
    [email protected] (failed)
    [email protected] (failed)
    [email protected] (failed)
    Did I miss something ?

    *** With PHPMailer ***
    Mailer : PHPMailer
    SMTP Host : localhost
    SMTP Port : 465 / 587 (I tried with both)
    SMTP Usename : [email protected]
    SMTP Password : my password
    From Email : [email protected]
    SMTP Authentication [0 or 1] : 1
    Results for email verification message delivery : failed for all email adresses listed above
    Does ISPConfig installation with PHP7 include PHPMailer ?
    Does PHPMailer require some extra settings, or an update to fit my use case ?

    These are questions to be related with what you think is the easiest, or better fit such this webapp usage :
    Can you please give a roadmap for further tests with PHP Mail (I heard about postfix, sendmail…) ?
    If ISPConfig can generate DKIM keys for PHPMailer, do I have to copy/paste these keys data in related DNS zone on side of my hosting provider ?

  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    You can let PHPMailer use a SMTP account on your server. If DKIM is enabled for the domain, it will be signed by the SMTP server. You can install PHPMailer following this:
  3. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    You should be able to tell from your log files why the various emails failed.

    For phpmailer, it is possible you need to use the server's hostname rather than localhost so the ssl certificate matches the hostname you connect to.

    Yes, you have to publish the public key in your public dns servers.
  4. Keoz

    Keoz Member

    Meaning that ISPConfig installation does not include PHPMailer....

    OVH, my actual hosting and email provider (MX plan) does not handle DKIM key publishing : none field in DNS zone with dedicated label, despite customers are claiming for it since 2017…. !

    Would you then recommend me to transfer my domain name and email to another hosting service (e.g INFOMANIAK, or any of those you may suggest) ?

    If a DKIM key is set for sender's email address; e.g.[email protected]“, does this supposedly insure that mail delivery (to new account creators) should work, whatever the email server (SMTP Host) I prefer to set for PHPMailer ?

    Last edited: Apr 13, 2021
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    DKIM is a DNS TXT record, does your provider really not allow you to add a TXT record?
  6. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Ispconfig does not use phpmailer, so it wouldn't make any sense for it to be included; there are thousands of php classes that ispconfig does not use, and does not include. If you have an app which needs it, you include it with the app, or list it as an install requirement.
  7. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    And you can easily install it yourself when needed.
  8. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    If you have DKIM setup for a domain, and you send mail via smtp (on any of ports 25, 465 or 587) through your server from a user on that domain, it will be dkim signed; it doesn't matter if you use 'localhost', the server's actual hostname, or an ip address to connect to, as long as your client (eg. phpmailer in your case) accepts the connection info (eg. it doesn't reject the ssl certificate or similar). DKIM signing your mail will improve mail delivery rates, especially if you publish a restrictive DMARC policy, but certainly nothing ensures your mail will be delivered.
    Th0m likes this.
  9. Keoz

    Keoz Member


    This is what was said on some forums, but after verification, my hosting provider does allow it.

    It might be helpfull is to have ones’s opinions upon this complete step by step tutorial I found (link below), that matches the choice of PHP Mail over PHPMailer, and in which “Postal“ is preferred to “Postfix“ or “Sendmail“ to set a mail server on my VPS. Postal comes with a UI that makes it easier to test the deliverability of sent email... :

    /// TUTORIAL ///

    That said, I also have two questions, and your reply to these may help me (and maybe others) to proceed what is necessary with process resilience in mind :

    /// Q1 ///
    Unless I’ve misunderstood, conflicts or bugs may be avoided if other sending mail services (Postfix, Sendmail…) are deactivated. If right, what would you recommend to get this task done properly (rolling back remaining possible) ?

    /// Q2 ///
    How can I verify that message to end-user is signed (DKIM signature) when emailed from script running on my VPS ?

    Last edited: Apr 16, 2021
  10. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    First, I assume you mean you are considering installing postal on your web server? ISPConfig only supports postfix on the mail server.
    Correct, you would want to remove any other MTA. To uninstall postfix, 'apt remove postfix' should do it.
    Open a message which has been delivered and check the mail headers to see if the DKIM-Signature header is there.
  11. Keoz

    Keoz Member

  12. Keoz

    Keoz Member

    Does the domain entry for DKIM key have to match FQDN, or can it be a sub-domain name if the script to send notification emails is installed under path matching a sub-domain ?

  13. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    DKIM is created for an e-mail domain. Have you creted DKIM previously? DKIM key is created in ISPConfig in E-Mail tab, Domain, button "Domainkeys identified mail (DKIM)".
    You can create DKIM for every e-mail domain you have.
    If by FQDN you mean the hostname.domain.tld of the server, you can create e-mail domain domain.tld and then DKIM for that.
  14. Keoz

    Keoz Member

Share This Page