这是通过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()
Run Code Online (Sandbox Code Playgroud)
通过调用此方法
Classname.Send_Mail(<emailid>,<password>,<destination email-id>,<subject>,<body>
Run Code Online (Sandbox Code Playgroud)
该代码工作正常,但需要在发送邮件时设置到期日期,以便发送的邮件必须在指定时间后自动从收件箱中删除。如有帮助,将不胜感激。
Expiry-Date
已替换Expires
为 SMTP 标头,以指示电子邮件消息的有效性已过期。请参阅RFC 4021 的相关部分。
也就是说,虽然它是标准化的,但我认为它还没有被广泛采用,并且标头并不能保证消息会被删除。不过, Microsoft Outlook 确实会显示带有删除线样式的过期邮件。
归档时间: |
|
查看次数: |
3344 次 |
最近记录: |