我已经nano /etc/postfix/main.cf
在主机服务器中安装并配置了 postfix 文件,当我尝试从主机服务器发送该文件时,它在主机上运行良好。但是当我从容器的 bash 终端输入相同的命令时,我收到此错误。echo "Test Postfix Gmail SMTP Relay" | mail -s "Postfix Gmail SMTP Relay Message" [email protected]
bash: mail: command not found
里面的配置如下/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
因此,我使用 ubuntu 作为主机,并使用一个发送电子邮件的简单 docker 容器。我希望能够使用主机中安装的 SMTP 服务器或 postfix 从 docker 的容器终端发送电子邮件。