Cron job don't send emals with Amazon SES

I have an issue with wp cron job and Amazon SES.

This is the syslog at every 15 minutes:

Aug 16 00:30:01 client-wp CRON[11773]: (web) CMD (cd /srv/www/cliensite/current && wp cron event run --due-now)
Aug 16 00:30:02 client-wp sSMTP[11775]: Creating SSL connection to host
Aug 16 00:30:02 client-wp sSMTP[11775]: SSL connection using RSA_AES_128_CBC_SHA1
Aug 16 00:30:03 client-wp sSMTP[11775]: 554 Transaction failed: Missing final '@domain'

If I test echo "test" | ssmtp me@domain.com works and send the email.

What does your mail configuration look like in Trellis?

The file mail.yml is this:

# Documentation: https://roots.io/trellis/docs/mail/
mail_smtp_server: email-smtp.eu-west-1.amazonaws.com:587
mail_admin: servicios@crea.me
mail_hostname: crea.me
mail_user: AKIAIXXXXXXXXXX7ZFA
mail_password: "{{ vault_mail_password }}" # Define this variable in group_vars/all/vault.yml

Did you Google that error? There’s a ton of results for “Amazon SES Missing final”. This doesn’t seem to be a Trellis specific issue.

Sorry, I think it colud be a problem on ssmtp.conf template or with the cron jobs.
I solved the problem with two solutions found googling:

The problem is SES requires a domain in both the “from” and “to” fields

From here solve the TO address: adding a MAILTO="user@domain.com" in cronfle

#Ansible: client WordPress cron
MAILTO=servicios@crea.me
*/15 * * * * web cd /srv/www/client/current && wp cron event run --due-now

From here solve FROM addres:

When ssmtp is installed, it creates a link from /usr/sbin/sendmail to /usr/sbin/ssmtp. What I did was delete the link and created a sendmail file that contains the following:

sed "s/From: root /From: root@mydomain.com /" | /usr/sbin/ssmtp $*

Now any mail sent from root will get rewritten to root@mydomain.com

Finally, if you don’t want receive emails from Cron Daemon at every execution you can set MAILTO="" in the cronfile.

Thanks, maybe there’s something we can automatically in Trellis to make this better. Would you mind opening an issue on the repo?

Hi @pacotole

Is it ok if you add more information on what you did to delete the link and created a sendmail file?
I don’t understand how to do that. Having similar problem with Mailgun too

Thank you

Sorry for my late reply.

You need to do this steps as root (or with sudo):

$ rm /usr/bin/sendmail  # remove sendmail link
$ nano /usr/bin/sendmail  # create sendmail file
# paste: sed "s/From: root /From: root@mydomain.com /" | /usr/sbin/ssmtp $*
# save and exit (Ctrl+O Ctrl+X)
$ chmod 777 /usr/bin/sendmail  # add execution perms to all
1 Like

pacotole how does mail sent from your server look like? From name is root and address is root@yourdomain.com? Do you have FromLineOverride specified as Yes or No?

Did a fix for this ever make it in to Trellis?

This issue caused me a world of pain a week or so ago. The above solutions are no good if servers are reprovisioned – these changes need to make their way into the ansible scripts.

I think that this fix might address this old issue.