gpt4 book ai didi

docker - 如何使用dockerized邮件服务器从Ubuntu服务器发送邮件

转载 作者:行者123 更新时间:2023-12-02 18:20:20 25 4
gpt4 key购买 nike

我正在寻找一种以编程方式从Linode Ubuntu服务器发送电子邮件的简单方法(而不是批量发送或发送垃圾邮件,而是简单的iOT类型通知)。我已经启动并运行了一个dockerized postfix / dovecot系统,但是我不知道如何从容器外部使用它。我已经研究了sendmail,但是由于我已经有配置的SMTP服务器,因此这似乎是重复的。我的问题是我可以在我的Ubuntu服务器上安装什么,以便允许我从使用Docker容器中现有SMTP服务器的命令行(脚本)发送简单电子邮件?

最佳答案

这类似于拥有必须发送电子邮件as described here的Jenkins容器:

For containerized Jenkins system, mail server can also be configured in same Manage Jenkins page, E-mail Notification section.
The only difference is the IP/hostname provided to SMTP server option. Instead of providing the known SMTP server’s IP and host, one should use the IP of docker0.

For corporate network, you may have to use an SMTP relay server instead. For those cases, you can configure SMTP communication by setting up Postfix.

After installing, update /etc/postfix/main.cf with correct relay information: myhostname, myorigin, mydestination, relayhost, alias_maps, alias_database.



但:

要在Postfix上进行两项更改,以将其公开给一台主机上的Docker容器。

  1. Exposing Postfix to the docker network, that is, Postfix must be configured to bind to localhost as well as the docker network.
  2. Accepting all incoming connections which come from any Docker containers.

Docker bridge (docker0) acts a a bridge between your ethernet port and docker containers so that data can go back and forth.
We achieve the first requirement by adding the IP of docker0 to inet_iterfaces.

For the second requirement, the whole docker network as well as localhost should be added to mynetworks.

关于docker - 如何使用dockerized邮件服务器从Ubuntu服务器发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54383751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com