Ssmtp working but WordPress emails fail

I’m running Trellis/Bedrock/Sage on a subdomain that has the same hostname as the email configured in the Trellis ssmtp. The mail relay is going through Microsoft Office 365. If I ssh into the box and just run ssmtp from the command line it works fine.

However, trying to use the forgot password function in Wordpress I get:

The email could not be sent. Possible reason: your host may have disabled the mail() function.

From the Trellis docs I was under the impression that the wp_mail function was already filtered by default to use smtp, but maybe that’s not the case? Do I need to do additional configuration? I don’t see any errors pertaining to this at all in logs. Any guidance on this would be greatly appreciated.

Edit: I should maybe also mention that I initially provisioned and deployed without SSL and without the SMTP settings configured. After updating I reprovisioned, ran without error.

The only time that message should appear is when you have misconfigured the SMTP settings

1 Like

Office365 is really picky about whether your “send as” user matches your SMTP username. The one time I decided to wrestle this I had to grant my account “send-as” permissions for every user on the O365 domain. Since then I’ve just used mailgun for everything. It’s muuuuch simpler.


Thanks @MWDelaney, that was the issue. Looks like the default email used by Wordpress (at least for password recovery) is wordpress@hostname. I used the wp_mail_from filter to change this to the email set in admin_email in the main Wordpress settings and then entered the email used for authentication in mail.yml. That seems to have satisfied the Office365 server.