Configure host base Postfix and send emails using a container

I have installed and configured the nano /etc/postfix/main.cf file for postfix in the host server and when I try to send it from the host server echo "Test Postfix Gmail SMTP Relay" | mail -s "Postfix Gmail SMTP Relay Message" it's running fine from the host machine. But when I enter the same command from the bash terminal of the container, I get this error bash: mail: command not found.

Here is the configuration inside /etc/postfix/main.cf:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated
defer_unauth_destination
myhostname = demo.example.host
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost.example.host, , localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 172.17.0.2 172.17.0.3 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = 172.17.0.1
inet_protocols = all
# Enables SASL authentication for postfix
smtp_sasl_auth_enable = yes
# Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
# Location of sasl_passwd we saved
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Enable STARTTLS encryption for SMTP
smtp_tls_security_level = encrypt
# Location of CA certificates for TLS
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

So, I am using ubuntu as a host machine, and a simple docker container that sends the email. I want to be able to send the email from the docker's container terminal using the installation of SMTP server or postfix in the host machine.

6 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like