在 bash 脚本中使用 openssl s_client 发送带有附件的电子邮件

发布于 2025-01-19 05:01:43 字数 157 浏览 2 评论 0原文

如何使用openssl s_client命令将带有附件的电子邮件发送为:

openssl s_client -crlf -quiet -starttls smtp -connect $SMTPHostName:587 

使用bash脚本

How to send an email with attachment using openssl s_client command as:

openssl s_client -crlf -quiet -starttls smtp -connect $SMTPHostName:587 

using bash script

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月打碎记忆 2025-01-26 05:01:43

您可以将SMTP命令输送到openssl s_client的

$ openssl s_client -crlf -quiet -starttls smtp -connect smtp.xs4all.nl:587 <<< QUIT

结果:

depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = smtp.xs4all.nl
verify return:1
250 8BITMIME
221 2.0.0 Bye

可以使用“ help”显示可用命令。
命令序列通常是这样的:

helo mail.example.com
data
To: [email protected]
From: [email protected]
Date: Fri, 15 dec 2021 14:00:00 -0200
Message-ID: <[email protected]>

This is a test
.

NB。可能需要一个身份验证。

要添加类似以下内容的附件,需要添加到电子邮件中。

Content-Type: image/png;
              name="bullet.png"
Content-Transfer-Encoding: x-uuencode

begin 664 bullet.png
MB5!...
<snipped>
'
end

文件bullet.png用uuencode编码为ASCII,并添加到消息中。您可以使用其他MIME格式。

命令可能因邮件服务器而异,具体取决于邮件传播和RFC的支持

You can pipe smtp commands into the openssl s_client with

$ openssl s_client -crlf -quiet -starttls smtp -connect smtp.xs4all.nl:587 <<< QUIT

Result:

depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = Sectigo Limited, CN = Sectigo RSA Domain Validation Secure Server CA
verify return:1
depth=0 CN = smtp.xs4all.nl
verify return:1
250 8BITMIME
221 2.0.0 Bye

Available commands can be shown with 'help'.
The sequence of commands is usually something like this:

helo mail.example.com
data
To: [email protected]
From: [email protected]
Date: Fri, 15 dec 2021 14:00:00 -0200
Message-ID: <[email protected]>

This is a test
.

NB. There may be an authentication needed.

To add an attachment something like the following needs to be added to the email.

Content-Type: image/png;
              name="bullet.png"
Content-Transfer-Encoding: x-uuencode

begin 664 bullet.png
MB5!...
<snipped>
'
end

The file bullet.png was encoded with uuencode to ascii and added to the message. You can use other MIME formats.

Commands can vary from mailserver to mailserver depending on what for mailextensions and RFC's they support

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文