这是通过python程序发送邮件的方法。
def Send_Mail(self, username, password, receiver, subject, body):
username = str(username)
password = str(password)
receiver = str(receiver)
subject = str(subject)
body = str(body)
Username = username
Password = password
Sender = username
Destination = [receiver]
Subject = subject
Content = body
text_subtype = 'html'
SMTPserver = 'smtp.gmail.com'
msg = MIMEText(Content, text_subtype)
msg['Subject'] = Subject
msg['From'] = Sender
conn = SMTP(SMTPserver)
conn.set_debuglevel(False)
conn.login(Username, Password)
conn.sendmail(Sender, Destination, msg.as_string())
conn.close()
通过调用此方法
Classname.Send_Mail(<emailid>,<password>,<destination email-id>,<subject>,<body>
此代码运行良好,但需要在发送邮件时设置到期日期,以便发送的邮件必须在指定时间后自动从收件箱中删除。帮助将不胜感激。