lando/platformsh

Sending mail locally is broken (bad msmtprc config)

Opened this issue · 0 comments

lando v3.6.2
Drupal 9

Whenever I try to send email with Drupal, I get a "Cannot send email" error.

So with help from platform.sh Slack, I tried a test email:

php -r 'mail("[mail@example.com](mailto:mail@example.com)", "test message", "just testing", "From: [tester@example.com](mailto:tester@example.com)");',

This gave the error: sendmail: /etc/msmtprc: line 6: command host needs an argument.

A Stack Overflow search led me to this answer, which suggests a problem with msmtprc.

So I did lando ssh; vi /etc/msmtprc:

defaults
syslog on
timeout off

account platform
host
from

account default : platform

I think this is incorrect because when I check vi /etc/msmtprc.psh-tmpl, I see:

defaults
syslog on
timeout off

account platform
host ${info.get("mail_relay_host_tmpl", "")}
from ${info.get("mail_smtp_from", "")}

account default : platform

So it seems that the values for host and from are not getting filled in for some reason.

I don't really know anything about msmtprc so this is as far as I got with debugging.