【问题标题】:how to send mail with expiry date, auto delete from inbox如何发送带有到期日期的邮件,从收件箱中自动删除
【发布时间】:2012-11-05 17:24:35
【问题描述】:

这是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>

这段代码运行良好, 但需要在发送邮件时设置有效期,这样发送的邮件必须在指定时间后自动从收件箱中删除。 帮助将不胜感激。

【问题讨论】:

  • 是什么让您觉得电子邮件支持这样的功能?我不知道有任何电子邮件客户端支持“自动删除”收到的电子邮件..
  • 我认为 E-mailsGmails 将在 9 个月后自动过期(我不确定),所以想。
  • Gmail 只是标准的互联网电子邮件,具有非常好的用户界面。如果 Google 自动使电子邮件过期,那将是他们的选择,但它不是任何标准的一部分,或者您可以通过设置额外的标头来实现。
  • 不限制这个想法只使用 SMTP,其他服务器,如 POP3 serverIMAP server,询问是否可以使用任何其他服务器?

标签: python smtp gmail


【解决方案1】:

Expiry-Date 被替换为 Expires 作为 SMTP 标头,以指示电子邮件的有用性到期。见the relevant section of RFC 4021

也就是说,虽然它是标准化的,但我认为它并没有被广泛采用,而且标头并不能保证消息会被删除。不过,Microsoft Outlook 支持show an expired message with a strikethrough style

【讨论】:

    【解决方案2】:

    在邮件中设置“Expiry-Date”标头,大多数客户端都会确认它(并且过期、标记为已删除、请求许可等)

    【讨论】:

      【解决方案3】:

      据我所知,在 SMTP 或 another mail related standard 的任何地方都没有“自动删除”之类的东西。此外,我从未听说过这样的“功能”。

      所以答案是:你不能

      (也许他们是支持此类事情的邮件客户端,但这将是“仅在客户端 X 中有效”功能。因此,要获得更有用的答案,您必须提供目标客户端。)

      【讨论】:

      • 如下所述,过期是标准的一部分。但不保证客户端 X 支持它。所以答案是:是的,你可以,但不清楚收件人客户是否支持它。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 2015-09-20
      • 1970-01-01
      • 1970-01-01
      • 2014-08-12
      相关资源
      最近更新 更多