Closed chaosbunker closed 7 years ago
Ok, I figured it out:-) in case anyone wants to know how to do this, this is how i did it (or look in my fork, branch phpfpm-and-sendmail)
If anyone knows a better way of doing this or if my way is in any way bad practice or possibly causing issues, please let me know! For me this is working fine though:-)
define(`SMART_HOST',`${MAILCOW_HOSTNAME}')
php-fpm-mailcow:
[...]
command: /bin/bash -c "envsubst < /etc/mail/sendmail.mc.template > /etc/mail/sendmail.mc &&
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf &&
service sendmail restart &&
php-fpm -d date.timezone=${TZ}"
volumes:
- ./data/conf/phpfpm/php-mail.conf:/usr/local/etc/php/conf.d/mail.ini:ro
- ./data/conf/phpfpm/sendmail.mc.template:/etc/mail/sendmail.mc.template:ro
hostname: ${MAILCOW_HOSTNAME}
[...]
I have added a simple website with a php contact form that normally sends emails via the mail() function ... since there is no MTA in the phpfpm container this does not work.
how can I use sendmail of the postfix container to send mail from that form (or at some point from a wordpress blog)?
I first tried by customizing the Dockerfile of the phpfpm container and added ssmtp and told ssmtp to use postfix-mailcow as the mailhub, mail comes through to the postfix container but can't be processed. this is the error message:
Apr 18 11:01:09 mx postfix/smtpd[331]: connect from mailcowdockerized_php-fpm-mailcow_1.mailcowdockerized_mailcow-network[172.22.1.3]
Apr 18 11:01:09 mx postfix/smtpd[331]: Anonymous TLS connection established from mailcowdockerized_php-fpm-mailcow_1.mailcowdockerized_mailcow-network[172.22.1.3]: TLSv1 with cipher AES128-SHA (128/128 bits)
Apr 18 11:01:09 mx postfix/smtpd[331]: fatal: host/service dovecot/10001 not found: Name or service not known
Apr 18 11:01:10 mx postfix/master[320]: warning: process /usr/lib/postfix/sbin/smtpd pid 331 exit status 1
Apr 18 11:01:10 mx postfix/master[320]: warning: /usr/lib/postfix/sbin/smtpd: bad command startup -- throttling
i also tried adding and using sendmail instead of ssmtp but it fails because it does not have a FQDN in /etc/hosts and adding the mailcow hostname to the phpfpm container via docker-compose.yml but it didn't seem to work
but anyway, i ideally want to send mail through the postfix container directly. is there an elegant solution?