Sendmail host not found when running inside a docker container
Sendmail is trying to relay your e-mail through an SMTP server located here: mail.example.com. This is the builtin default config for sendmail on this image.
What you want to do is to pass the google SMTP config for sendmail, like this:
echo "Subject: test" | sendmail -v -f your@mail.com -au<your-gmail-account> -ap<your-gmail-password> -H 'openssl s_client -quiet -tls1 -connect smtp.gmail.com:465' your@mail.com
A practical example for:
- gmail account: your@gmail.com
- gmail password: 123456
Would look like this:
echo "Subject: test" | sendmail -v -f your@mail.com -auyour@gmail.com -ap123456 -H 'openssl s_client -quiet -tls1 -connect smtp.gmail.com:465' your@mail.com
sendmail --help
For reference, here is the sendmail --help
. You can get it from the image that you are using with:
docker run --rm php:fpm-alpine sendmail --help
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.Usage: sendmail [-tv] [-f SENDER] [-amLOGIN 4<user_pass.txt | -auUSER -apPASS] [-w SECS] [-H 'PROG ARGS' | -S HOST] [RECIPIENT_EMAIL]...Read email from stdin and send itStandard options: -t Read additional recipients from message body -f SENDER For use in MAIL FROM:<sender>. Can be empty string Default: -auUSER, or username of current UID -o OPTIONS Various options. -oi implied, others are ignored -i -oi synonym, implied and ignoredBusybox specific options: -v Verbose -w SECS Network timeout -H 'PROG ARGS' Run connection helper. Examples: openssl s_client -quiet -tls1 -starttls smtp -connect smtp.gmail.com:25 openssl s_client -quiet -tls1 -connect smtp.gmail.com:465 $SMTP_ANTISPAM_DELAY: seconds to wait after helper connect -S HOST[:PORT] Server (default $SMTPHOST or 127.0.0.1) -amLOGIN Log in using AUTH LOGIN (-amCRAM-MD5 not supported) -auUSER Username for AUTH -apPASS Password for AUTHIf no -a options are given, authentication is not done.If -amLOGIN is given but no -au/-ap, user/password is read from fd #4.Other options are silently ignored; -oi is implied.Use makemime to create emails with attachments.