Welcome to Centmin Mod Community
Register Now

Email How I setup Amazon SES donotreply address easily

Discussion in 'Domains, DNS, Email & SSL Certificates' started by Atrix, Oct 21, 2018.

  1. Atrix

    Atrix Member

    37
    13
    8
    Oct 7, 2018
    Ratings:
    +38
    Local Time:
    7:36 PM
    1.15.3
    MariaDB 10.1.36
    Hoping this can help someone else who really will only plan on using email to send automated messages for registration/etc to people who use your website from the server. While there's ways of setting it up so they could reply to these emails this is how to set up a donotreply one fairly easily that will score a 10/10 on mail-tester.com using php to send the mail.

    I recommend before starting this process you take a snapshot of your droplet in case you are unsatisfied with anything or something breaks and you can't fix it.

    1) Signup for Amazon SES, not going to cover this in detail for you. Here's where to signup though and what to bookmark for yourself to manage it: http://console.aws.amazon.com

    2) Search for Simple Email Service in the console

    3) Pick a region, the easiest to configure from is US West (Oregon) because their tutorial uses that as an example.

    4) Click Domains and verify a new domain, they should guide you through it but it will take access to your DNS settings.

    5) Click on SMTP Settings

    6) Click create my SMTP settings

    7) Expand the box that has your username and key, and save these somewhere safe and secure you'll need them.

    8) on your server as root
    yum install sendmail sendmail-cf m4
    make sure to his yes and install it all

    8) Follow very carefully the directions here, armed with your account setup properly and server having everything it needs.
    Integrating Amazon SES with Sendmail - Amazon Simple Email Service

    9) If you followed it correctly the test they listed should work. Now you have to make it work with php.

    10) in /usr/local/lib/php.ini comment out the sendmail_path line and replace it with this:
    sendmail_path = /usr/lib/sendmail -t -i -fdonotreply@mydomain.com

    11)type
    service php-fpm restart

    12) go to mail-tester.com and copy the test email address, intput it in the php script in the next step for the mail-tester.com address

    13) in your /home/nginx/domains/mydomain.com/public folder create a php script, call it what you like (emailtest.php for example):
    <?php
    ini_set('display_errors', 1);
    error_reporting(-1);
    mail ('test-asfaw@mail-tester.com', 'Postfix Test', 'A test email') || print_r(error_get_last());
    ?>

    Run the file through your web browser by going to http://mydomain.com/emailtest.php (or whatever you named it)


    14) go back to your mail-tester.com tab and click the button to see how you did. It should be a 10/10 score.

    I won't be able to help anyone troubleshoot due to needing to devote time to my own stuff but I hope this guide is helpful to some people. Note that it will only work for doing one domain from your server/droplet. Maybe one day I'll figure out how to get it working for multiple on the same server.

    I've had to do this multiple times before so for me it took about 10 mins. But it might take someone doing it the first time a lot longer.
     
    Last edited: Oct 21, 2018
  2. eva2000

    eva2000 Administrator Staff Member

    53,488
    12,130
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,672
    Local Time:
    11:36 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I'd be care with this as Centmin Mod installs Postfix MTA server for mail outbound. You don't want to run sendmail MTA at the same time.

    Usually your web app/script will have a from email field option to set i.e. Xenforo and Vbulletin forum software has such so mail set to Amazon SES via 3rd party smtp server will automatically have the correct from email assigned to it.
     
  3. Atrix

    Atrix Member

    37
    13
    8
    Oct 7, 2018
    Ratings:
    +38
    Local Time:
    7:36 PM
    1.15.3
    MariaDB 10.1.36
    Thank you for that info, the test mails I sent were sending from nginx@localdomain and then I changed the hostname and it was nginx@hostname this seemed true even if i was putting a from address to the php mail function. The SES setup has you set what sendmail will send your email as it might be possible to not have the php.ini change. As for installing with yum the sendmail, I tried to not do it, and saw sendmail was on the server, but it was missing the makemap binary which is required and none of the files were in /etc/mail I needed or anywhere it seemed that I needed to follow for the amazon setup. However after I installed them all of it was there and it is definitely working now. I'll try to disable the postfix MTA.

    edit update:
    systemctl list-unit-files | grep postfix shows postfix disabled and
    systemctl list-unit-files | grep sendmail shows sendmail enabled so it seems the yum installer smartly disabled it for me
    netstat -tulp also shows sendmail as being what is used on the smtp port so hopefully that means there will be no issues

    Also the software I am using doesn't seem to have any SES integration features. It just uses the php mail function.
     
    Last edited: Oct 21, 2018