在Bottle Cork中更正Gmail的SMTP URL?

时间:2014-07-16 19:56:14

标签: python smtp gmail settings bottle

对于使用Bottle Cork,需要smtp_url。我想使用我的Gmail帐户发送电子邮件。我已尝试过多种变体,来自" smtp://smtp.gmail.com"到" smtp://smtp.gmail.com",什么都行不通。也许有人知道正确的设置?

1 个答案:

答案 0 :(得分:0)

似乎答案已在评论中发布,感谢@Padraic: smtp_urlcork.cork.Mailer配置中的cork.Cork()参数应设置为starttls://username:password@smtp.gmail.com:587,如下所示:

mailer = cork.cork.Mailer(sender='yourgmail@gmail.com',smtp_url='starttls://yourgmail:YourPassword@smtp.gmail.com:587')
mailer.send_email(email_addr='otherperson@example.com', subject='You have mail', email_text='Your email text')

您可能需要allow "less secure apps" in GMail,以便您的流程获得访问权限。