SAE Python 上使用Gmail 发送Mail 的小问题

目前 SAE 可用服务有 Mail ,可用 send_mail 或 EmailMessage 函数来发送邮件。

但我在使用时发现若使用 Gmail 则只能通过 send_mail 函数发送(不支持Html 格式)。

send_mail 的格式

1
2
3
4
from sae.mail import send_mail

send_mail('recipient@sina.com', 'subject', 'plain text', 
          ('smtp.sina.com', 25, 'me@sina.com', 'password', False))

没有具体文档,若用 EmailMessage 则会返回以下错误

1
AUTH LOGIN failed: '530 5.7.0 Must issue a STARTTLS command first.  j3sm46979194ibj.1', smtp.gmail.com:587 yq240 

Gmail ssl

是因为 Gmail 要求把 ssl 加密打开(启用 TLS ),即函数 send_mail 最后一个参数为 true 或者改一个端口号

1
2
3
4
from sae.mail import send_mail

send_mail("katherine@vampire.com", "invite", "to tonight's party",
          ("smtp.vampire.com", 25, "damon@vampire.com", "password", True))

本文网址: https://pylist.com/topic/7.html 转摘请注明来源

Suggested Topics

SAE+python+Tornado+pyTenjin 的完整示例

python 简单易懂,Tornado 高效易学,pyTenjin 轻巧快速,SAE 安全稳定使用门槛低。现在把他们结合在一起做了一个可运行在SAE 上的完整示例。...

SAE Python上开启gzip的方法

开启 gzip 的作用自不必说,可以省很多流出带宽,可以省很多云豆。昨天这个博客的云豆消耗,其中流出带宽就占九成多,开启后就会只占五成多。...

Leave a Comment