新(自)学Python,作业要求伪造邮件发件人地址,网上找了例子,自己再改改,只能做到改表面的发件人名字,yahoo中名字点开的邮件地址和gmail中名字后面跟着的邮件地址还是真的那个,到底怎么才能做到呢?目前失败的代码大概如下:
import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
sender = 'fromaddr@gmail.com'
password = 'XXXX'
recipients = ['toaddr@yahoo.com']
message = '''From: From Fake <Fakeemailaccount@gmail.com>
To: To Python <toaddr@yahoo.com>
Subject: SMTP Test
This is s test email.
'''
server.ehlo()
server.starttls()
server.login(user, password)
server.sendmail(sender, recipients, message)
求助求助求助~~~~
import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
sender = 'fromaddr@gmail.com'
password = 'XXXX'
recipients = ['toaddr@yahoo.com']
message = '''From: From Fake <Fakeemailaccount@gmail.com>
To: To Python <toaddr@yahoo.com>
Subject: SMTP Test
This is s test email.
'''
server.ehlo()
server.starttls()
server.login(user, password)
server.sendmail(sender, recipients, message)
求助求助求助~~~~