简体   繁体   English

发送预先准备的MIME电子邮件(使用PHP或Python)

[英]Sending a MIME email prepared beforehand (in PHP or Python)

Is it possible to send a MIME message as it is, without adding any headers? 是否可以按原样发送MIME消息而不添加任何标头? For example, if I have a correct MIME message with all headers and content saved to a text file, is it possible to use the contents of this file without modification and send it via SMTP? 例如,如果我有一个正确的MIME消息,其中所有标头和内容都保存到了文本文件中,是否可以不经修改地使用此文件的内容并通过SMTP发送? Apparently both python's SMTP.sendmail and PHP smtp::mail require at least "To:" and "From:", and passing the complete message to these functions doesn't seem to work. 显然,python的SMTP.sendmail和PHP smtp :: mail都至少需要“ To:”和“ From:”,并且将完整的消息传递给这些函数似乎不起作用。

您可以阅读第一行空白行,将其用作其他标题,然后将其余部分发送到正文中。

It appears from the documentation that python's SMTP.sendmail should take a sender, a set of recipients, and a verbatim MIME message like the one you have. 文档中可以看出,python的SMTP.sendmail应该包含一个发送者,一组接收者以及像您一样的逐字MIME消息。 (The split here between the sender/recipients and the message itself is because you're talking SMTP. The SMTP envelope determines the actual recipients and is actually independent of the message payload .) So you should be good to go with SMTP.sendmail . (此处,发件人/收件人与邮件本身之间的区别是因为您正在使用SMTP.sendmail 信封确定了实际的收件人 ,并且实际上独立于邮件有效负载 。)因此,最好使用SMTP.sendmail

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM