我已经创建了一个码头映像,在这里我安装了mailutils包,使用:
RUN apt-get update && apt-get install -y mailutils作为一个示例命令,我正在运行:
mail -s 'Hello World' {email-address} <<< 'Message body'当我在本地机器上执行相同的命令时,它会发送邮件。但是,在docker容器中,它没有显示任何错误,但是在指定的电子邮件id上没有收到任何邮件。
我试图在生成我的码头容器时使用--net=host参数。
下面是我的停靠命令:
docker run --net=host -p 0.0.0.0:8000:8000 {imageName}:{tagName} {arguments}我遗漏了什么吗?有人能解释一下这个问题背后的网络概念吗?
发布于 2017-05-24 16:47:48
安装ssmtp并配置为将所有邮件发送到中继主机。
发布于 2017-05-26 04:30:23
谢谢你的回复@pilasguru。ssmtp用于从码头容器内发送邮件。
为了使响应更详细,下面是我们需要做的事情。
RUN apt-get update && apt-get -y install ssmtp。/etc/ssmtp/ssmtp.conf上为ssmtp配置配置。
理想配置`
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root={root-name}
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub={smtp-server}
# Where will the mail seem to come from?
rewriteDomain={domain-name}
# The full hostname
hostname=c67fcdc6361d
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES`
my.conf的文件中。
您可以使用以下命令将它们复制到您的停靠容器中:
COPY ./my.conf /etc/ssmtp/ssmtp.confssmtp recipient_name@gmail.com < filename.txtecho -e "to: {to-addr}\nFrom: {from-addr}\nsubject: {subject}\n"| (cat - && uuencode /path/to/file/inside/container {attachment-name-in mail}) | ssmtp recipient_name@gmail.comuuencode可以由命令apt-get install sharutils安装。https://stackoverflow.com/questions/44158085
复制相似问题