Get the most out of your Centmin Mod LEMP stack
Become a Member

Email auto emails are not working

Discussion in 'Domains, DNS, Email & SSL Certificates' started by dooma, Jul 20, 2017.

  1. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    Please fill in any relevant information that applies to you:
    • CentOS Version: i.e. CentOS 7 64bit ?
    • Centmin Mod Version Installed: i.e. 123.09beta01
    • Nginx Version Installed: i.e. latest

    Hello

    I installed xenforo on my centminmod server but it's not sending the auto emails to users such as confirmation sign up mail .

    How can I solve that ?

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
    which web host ? vultr and some vps web hosts block smtp until you contact them to enable it and provide verification ID documentation.

    Troubleshooting Proper Email Sending



    To troubleshoot and/or ensure server sent emails via Postfix and from @domain.com your domains are delivered to their destination, do the following:

    Ensure Proper DNS Records Setup



    Ensure you have setup proper SPF, DKIM, DMARC & PTR DNS records for your main hostname i.e. hostname.domain.com and all @domain.com domain names as per outlined and linked instructions at here and Getting Started Guide Step 1 for main hostname (i.e. hostname.domain.com). The addons/opendkim.sh addon in 123.09beta01 will help you setup SPF/DKIM for main hostname of your Centmin Mod server. Without these DNS records for your main hostname and all domain names, the likelihood of your server sent and @domain.com sent emails delivering to target inboxes is lessened and may end up in user's spam box or being rejected.

    You can use these online DNS toolboxes to verify you have properly setup SPF, DKIM, DMARC and PTR DNS records

    Testing Server Sent Emails



    Use Newsletters spam test by mail-tester.com to send a test email from your server to the email address listed on the mail-tester.com web site - DO NOT leave the site yet though.

    To Test Server Sent Email

    For example if the site lists email web-1a0xv@mail-tester.com, in SSH you use mail command line to sent a test email with subject "mail-tester" and email contents of "mail-test"
    Code (Text):
    echo "mail-test" | mail -s "mail-tester" web-1a0xv@mail-tester.com
    


    To Test PHP mail() Sent Email

    To test PHP mail() function sent email, create a test-mail.php file (can be any name you want) with contents - changing the web-1a0xv@mail-tester.com to whatever you see on mail-tester.com web site
    PHP:
    <?php
        ini_set
    ('display_errors'1);
        
    error_reporting(-1);
        
    mail ('web-1a0xv@mail-tester.com''Postfix Test''A test email') || print_r(error_get_last());
    ?>
    save test-mail.php to /home/nginx/domains/domain.com/public/ web root directory and then open up domain.com/test-mail.php on your server. Remember to delete test-mail.php afterwards.

    Then click the 'then check your score' button on mail-tester.com site. It will check the email you sent and all it's email headers and give you a report card for the sending domain which is usually your main hostname in default Centmin Mod setups i.e. if sending email is root@hostname.domain.com, then sending domain is hostname.domain.com. You can ignore for subdomains the warning of no MX records for subdomain/hostnames as subdomain/hostnames don't require MX records only the @domain.com domain for receiving emails. This main hostname domain hostname.domain.com would be important for emails sent from your Centmin Mod server so need the required SPF, DKIM, DMARC and PTR DNS records mentioned above.

    This checks php mail() from server sent From = root@host.domain.com where host.domain.com is your main hostname. To test php mail() with a proper From = your@domain.com which maybe set in your PHP web app like Xenforo, Wordpress etc. Use a slight variation of the test-mail.php php file below - changing the web-1a0xv@mail-tester.com to whatever you see on mail-tester.com web site and changing YOURFROM@domain.com email address to the one you set in your PHP web app like Xenforo, Wordpress etc:
    PHP:
    <?php
        ini_set
    ('display_errors'1);
        
    error_reporting(-1);
       
    $headers "From: YOURFROM@domain.com";
        
    mail ('web-1a0xv@mail-tester.com''Postfix Test''A test email',$headers) || print_r(error_get_last());
    ?>
    then open up domain.com/test-mail.php on your server. Then click the 'then check your score' button on mail-tester.com site

    You can also test your @domain.com emails via SSH by adding the From email -r
    Code (Text):
    echo "mail-test" | mail -s "mail-tester" -r user@domain.com your@gmail.com
    

    Then checking your Gmail account including spam box for the email and looking at 'Show Original' for full headers.

    You can also test other target emails i.e. your @gmail.com account via SSH command
    Code (Text):
    echo "mail-test" | mail -s "mail-tester" your@gmail.com
    

    Then checking your Gmail account including spam box for the email and looking at 'Show Original' for full headers.

    Example of Gmail received email's 'Show Original' headers where my centminmod.com domain has working SPF, DKIM and DMARC DNS records setup from my 3rd party Google App/Gsuite email provider service. This is from email sent from my server where from email field was @centminmod.com.

    [​IMG]

    • My centminmod.com SPF record. For main hostname, use the SPF tools and generators linked to here to create your SPF record or use addons/opendkim.sh to generator both DKIM + SPF records. For @domain.com your 3rd party email provider would provide those for you i.e. Google Gsuite/Google App, Zoho, Outlook/Microsoft etc.
    • My centminmod.com DKIM record you need to specify the selector, so if you setup DKIM record as google._domainkey.centminmod.com, then the selector is google and for mxtoolbox.com DKIM check you'd enter it in format of domain:selector i.e. centminmod.com:google. For main hostname, Centmin Mod users can use addons/opendkim.sh to generate both the DKIM + SPF records. For @domain.com your 3rd party email provider would provide those for you i.e. Google Gsuite/Google App, Zoho, Outlook/Microsoft etc.
    • My centminmod.com DMARC record which is just a TXT DNS record so can be looked up as a TXT record as well. You can create DMARC records via free service at https://dmarc.postmarkapp.com/ but DMARC only works when you have both valid working SPF and DKIM DNS records. On the free service site, on the 'Send reports about this domain' field enter your domain.com or subdomain.domain.com (i.e. main hostname host.domain.com) in the field

    Notes For Web App Sent Emails



    Now if you use a web app like Wordpress, Xenforo, IP.Board, Magento, etc to sent emails. Then emails can either be sent as is via Centmin Mod Postfix MTA server via root@host.domain.com where receiving email servers would evaluate the SPF, DKIM, DMARC and PTR DNS records for sending domain @host.domain.com. If server's main hostname i.e. host.domain.com has valid DNS records, then email will be less likely sent to spam box or being rejected by receiving email server.

    If however, your web app allows you to set a from email field and you sent emails from say user@domain.com, then receiving email servers would evaluate the SPF, DKIM, DMARC and PTR DNS records for sending domain @domain.com so your domain.com would need to have those DNS records setup. The above Gmail 'Show Original' email headers screenshot above is an example of such cases.

    Using above mail-tester.com online tool is easiest way to check if all those SPF, DKIM, DMARC and PTR DNS records for sending domain @host.domain.com and @domain.com are setup correctly.

    Main Host Name Setup



    There is a reason the official Centmin Mod Getting Started Guide Step 1 outlines a proper main hostname SPF, DKIM, DMARC and PTR DNS records setup, as it is used for many purposes such as statistics hosting on main hostname vhost, phpmyadmin.sh installer setup of phpmyadmin on main hostname but also for ensuring proper email delivery from main hostname for emails sent from the server.

    As such your main hostname for your Centmin Mod server needs to be unique. The main hostname has a separate Nginx vhost config file at /usr/local/nginx/conf/conf.d/virtual.conf where server_name defined there is auto populated to the server main hostname.

    You can check if the main hostname is uniquely setup via this grep command in SSH type
    Code (Text):
    grep -rw server_name /usr/local/nginx/conf/conf.d/ | grep -w "$(hostname)"
    

    Ensure only 1 entry match is found and that is usually the one contained in main hostname's Nginx vhost config file at /usr/local/nginx/conf/conf.d/virtual.conf

    example output of 1 entry match you should expect as host.domain.com should only be referenced once in server_name for main hostname's Nginx vhost config file at /usr/local/nginx/conf/conf.d/virtual.conf
    Code (Text):
    grep -rw server_name /usr/local/nginx/conf/conf.d/ | grep -w "$(hostname)"
    /usr/local/nginx/conf/conf.d/virtual.conf:            server_name host.domain.com;
    


    If they don't match or if more than one Nginx vhost file is returned from the grep search, then you need to change and update DNS for the main hostname as per Centmin Mod Getting Started Guide Step 1 and then edit the server_name listed in /usr/local/nginx/conf/conf.d/virtual.conf to the newly changed main hostname.

    The main hostname domain i.e. host.domain.com is the domain that server sent emails via Postfix MTA is sent from, so needs to properly setup on server and with proper DNS records.

    Postfix pflogsumm Stats



    Centmin Mod by default installs pflogsumm tool for Postfix log statistics. Centmin Mod only provides the tool for your usage, interpretation and understanding of the output is left up to you to figure out.

    There's a default alias command you can type for today only stats, postfixlog

    The alias for postfixlog command is
    Code (Text):
    alias postfixlog='pflogsumm -d today --verbose_msg_detail /var/log/maillog'
    

    which is basically same as calling pflogsumm directly as
    Code (Text):
    pflogsumm -d today --verbose_msg_detail /var/log/maillog
    

    There's also other commands you can directly use to by invoking pflogsumm command.

    To see yesterday's stats instead of today
    Code (Text):
    pflogsumm -d yesterday --verbose_msg_detail /var/log/maillog
    

    Report for all /var/log/maillog* in sorted time ascending order
    Code (Text):
    pflogsumm $(ls -rt /var/log/maillog*)
    

    To filter on specific date of the month, i.e. Mar 26
    Code (Text):
    grep 'Mar 26' /var/log/maillog | pflogsumm --verbose_msg_detail
    


    Code (Text):
    grep 'Mar 26' /var/log/maillog | pflogsumm --verbose_msg_detail
    
    Grand Totals
    ------------
    messages
    
         23   received
         24   delivered
          0   forwarded
          0   deferred
          0   bounced
          0   rejected (0%)
          0   reject warnings
          0   held
          0   discarded (0%)
    
      24609   bytes received
      27282   bytes delivered
          3   senders
          2   sending hosts/domains
          5   recipients
          3   recipient hosts/domains
    
    
    Per-Hour Traffic Summary
    ------------------------
        time          received  delivered   deferred    bounced     rejected
        --------------------------------------------------------------------
        0000-0100           0          0          0          0          0
        0100-0200           0          0          0          0          0
        0200-0300           0          0          0          0          0
        0300-0400           0          0          0          0          0
        0400-0500           3          3          0          0          0
        0500-0600           2          2          0          0          0
        0600-0700           2          2          0          0          0
        0700-0800           2          2          0          0          0
        0800-0900          10         11          0          0          0
        0900-1000           3          3          0          0          0
        1000-1100           1          1          0          0          0
        1100-1200           0          0          0          0          0
        1200-1300           0          0          0          0          0
        1300-1400           0          0          0          0          0
        1400-1500           0          0          0          0          0
        1500-1600           0          0          0          0          0
        1600-1700           0          0          0          0          0
        1700-1800           0          0          0          0          0
        1800-1900           0          0          0          0          0
        1900-2000           0          0          0          0          0
        2000-2100           0          0          0          0          0
        2100-2200           0          0          0          0          0
        2200-2300           0          0          0          0          0
        2300-2400           0          0          0          0          0
    
    Host/Domain Summary: Message Delivery
    --------------------------------------
     sent cnt  bytes   defers   avg dly max dly host/domain
     -------- -------  -------  ------- ------- -----------
         16    21656        0     0.1 s    0.1 s  host.domain.com
          6     4891        0     0.9 s    1.1 s  domain.com
          2      735        0     2.0 s    2.1 s  mail-tester.com
    
    Host/Domain Summary: Messages Received
    ---------------------------------------
     msg cnt   bytes   host/domain
     -------- -------  -----------
         21    21726   host.domain.com
          2     2883   domain.com
    
    Senders by message count
    ------------------------
         19   root@host.domain.com
          2   user+host@domain.com
          2   nginx@host.domain.com
    
    Recipients by message count
    ---------------------------
         16   root@host.domain.com
          3   user+postfixx@domain.com
          2   user+host@domain.com
          2   web-zxxxc@mail-tester.com
          1   username@domain.com
    
    Senders by message size
    -----------------------
      20991   root@host.domain.com
       2883   user+host@domain.com
        735   nginx@host.domain.com
    
    Recipients by message size
    --------------------------
      21656   root@host.domain.com
       2883   user+host@domain.com
       1512   user+postfixx@domain.com
        735   web-zxxxc@mail-tester.com
        496   username@domain.com
    
    message deferral detail: none
    
    message bounce detail (by relay): none
    
    message reject detail: none
    
    message reject warning detail: none
    
    message hold detail: none
    
    message discard detail: none
    
    smtp delivery failures: none
    
    Warnings: none
    
    Fatal Errors: none
    
    Panics: none
    
    Master daemon messages: none
    
     
  3. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    Linode.

    Where should I put these records SPF, DKIM, DMARC & PTR DNS records on the domain registrar panel ?

    Test server email is working but the php is not when I tested that on mail-tester.com

    Thanks
     
  4. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
    yes whereever your domain's DNS records are managed/hosted.
     
  5. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    I'm using ZOHO so should I remove it or can it be added beside ZOHO ?
     
  6. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
    no do not remove ZOHO DNS records, those ZOHO should have their own DKIM, SPF records you should of setup. But you need to add additional ones for your server's main hostname as outlined at Email - Steps to ensure your site/server email doesn't end up in spam inboxes

    as per above
    The 2nd set evaluated from @domain.com will be the DKIM/SPF records ZOHO provided you to setup i.e. Email - Zoho Mail Free @yourdomain.com Email Provider Setup Information
     
    Last edited: Jul 20, 2017
  7. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    Hi @eva2000

    What should be the name of my DNS records (SPF, DKIM.. ) at my cloudflare?

    server01.mydomain.com
    or
    mydomain.com

    Thanks
     
  8. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    Another Q please,

    Why mail-tester.com is giving me this message although I added my google mx records :


    And also giving me this message:


    Thanks
     
  9. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
    subdomains do not need MX records only non-subdomain i.e. domain.com so can ignore that
    sounds like you do not have proper SPF text record and Dkim setup for server1.mydomain.com as per Email - Steps to ensure your site/server email doesn't end up in spam inboxes you can use addons/opendkim.sh addon script which when ran will give your the DKIM and SPF txt records to add for your server1.mydomain.com (which should match your server's main hostname)
     
  10. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    This is not subdomain. This my server name (server1.mydomain.com)

    So Am asking what should be the name of the record SPF/DKIM the full server name(server1.mydomain.com) or only the domain without www (mudomain.com)

    Thanks
     
  11. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    I added it. should I delete the DKIM and SPF of google from my DNS panel ?

    and this
     
  12. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
    that is a subdomain anything.domain.com is a subdomain, only domain.com is non-subdomain
     
  13. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
    no do not delete you have 2 sets of SPF/DKIM

    1. for @domain.com provided by google apps
    2. for @server1.domain.com provided by addons/opendkim.sh script

    as per Email - Steps to ensure your site/server email doesn't end up in spam inboxes

     
  14. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    Thanks I finished it and got score 7/10 because of MX records that will be ignored.

    I make some tests : Yahoo and Gmail are receiving messages but hotmail server is not. I don't know why.
     
  15. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
  16. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    Regarding the PTR when I tried to add reverse dns at linode
    But it accepts it if i removed server1 and used only the domain. ?
     
  17. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
  18. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    and for setting the PTR which one should I use server1 > A record or domain.com > A record ??

    Thanks
     
  19. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    11:41 PM
    Nginx 1.13.x
    MariaDB 5.5
    PTR is for your local server email sending domains so you should have for server1.domain.com for emails sent from @server1.domain.com

    google apps already has their own PTR for emails sent from @domain.com
     
  20. dooma

    dooma Premium Member Premium Member

    222
    22
    18
    Oct 15, 2016
    Cairo
    Ratings:
    +27
    Local Time:
    3:41 PM
    HELLO
    I followed all the steps. Yahoo receiving emails fine. Hotmail not receiving anything. Gmail only received messages with email@mydomain.com but email@gmail.com is not receiving.