0
我可以在本地使用以下腳本接收電子郵件。在Docker容器中通過curl(smpt)發送電子郵件
rtmp_url="smtp://smtp.xxx.com:25"
rtmp_from="[email protected]"
rtmp_to="[email protected]"
file_upload="mail.txt"
echo "From: $rtmp_from
To: $rtmp_to
Subject: example of mail
Cc:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=\"MULTIPART-MIXED-BOUNDARY\"
--MULTIPART-MIXED-BOUNDARY
Content-Type: multipart/alternative; boundary=\"MULTIPART-ALTERNATIVE-BOUNDARY\"
--MULTIPART-ALTERNATIVE-BOUNDARY
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
This is an email example. This is text/plain content inside the mail.
--MULTIPART-ALTERNATIVE-BOUNDARY--
--MULTIPART-MIXED-BOUNDARY
Content-Type: application/octet-stream;
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"logs.txt\"" > ./mail.txt
cat ./mail.txt | base64 >> ./mail.txt
# end of uploaded file
echo "--MULTIPART-MIXED-BOUNDARY--" >> ./mail.txt
echo "sending ...."
curl --url 'smtp://smtp.xxx.com:25' --ssl-reqd --mail-from $rtmp_from --mail-rcpt $rtmp_to -T './mail.txt' --insecure
但我試圖在碼頭容器中運行此腳本。容器中出現此錯誤:無法連接到smtp.xxx.com:25;沒有到主機的路由。 在我的電腦中,我將mailhub更改爲/etc/ssmtp/ssmtp.conf中的smtp.xxx.com,因此它在本地工作。我對碼頭工人是新手,不知道如何在碼頭集裝箱中實現這一點。請幫忙。
你在辦公室網絡中做這個嗎?你有你自己的/自定義的DNS服務器嗎? –
是的,在辦公室網絡。但是當我在終端上運行時,我可以收到電子郵件。我不知道如何在Docker容器中配置。 – Aki