0

I'm trying to setup email with postfix image and msmtp from php. Sending emails from command line works from wordpress container to postfix using msmtp (I'm using docker compose but I think it's not related). But in php it don't work.

Postfix log show this:

Feb 14 12:00:09 36a1774df087 postfix/smtpd[141]: connect from volume_wordpress_1.volume_default[172.23.0.4]
Feb 14 12:00:09 36a1774df087 postfix/smtpd[141]: warning: Illegal address syntax from volume_wordpress_1.volume_default[172.23.0.4] in MAIL command: <wordpress@10.39.91.81>
Feb 14 12:00:09 36a1774df087 postfix/smtpd[141]: disconnect from volume_wordpress_1.volume_default[172.23.0.4]
Feb 14 12:03:29 36a1774df087 postfix/anvil[143]: statistics: max connection rate 1/60s for (smtp:172.23.0.4) at Feb 14 11:58:44
Feb 14 12:03:29 36a1774df087 postfix/anvil[143]: statistics: max connection count 1 for (smtp:172.23.0.4) at Feb 14 11:58:44
Feb 14 12:03:29 36a1774df087 postfix/anvil[143]: statistics: max cache size 1 at Feb 14 11:58:44

php config look like this:

sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t -i"

The same command work when I run it from terminal. But from php it show above error.

Do I need to change wordpress@10.39.91.81 (it's intranet public machine address, wordpress is name of the service in docker-compose.yml)? How can I do that?

jcubic
  • 230
  • 1
  • 4
  • 14

1 Answers1

0

I've found the problem in answer to this question on StackOveflow Sending mail through terminal using msmtp works fine, but doesn't work with php mail()

The problem was file permission to /etc/msmtprc it was owned by root, executing:

chown www-data:www-data /etc/msmtprc
chmod 600 /etc/msmtprc

fixed the issue

jcubic
  • 230
  • 1
  • 4
  • 14