标头注入不是发送邮件的方式,而是构建邮件的方式。检查电子邮件包,使用该电子邮件包构造邮件,对其进行序列化,然后
/usr/sbin/sendmail使用子流程模块将其发送至:
import sysfrom email.mime.text import MIMETextfrom subprocess import Popen, PIPEmsg = MIMEText("Here is the body of my message")msg["From"] = "me@example.com"msg["To"] = "you@example.com"msg["Subject"] = "This is the subject."p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)# Both Python 2.X and 3.Xp.communicate(msg.as_bytes() if sys.version_info >= (3,0) else msg.as_string())# Python 2.Xp.communicate(msg.as_string())# Python 3.Xp.communicate(msg.as_bytes())


