无法使用pyramid_mailer和gmail发送电子邮件 [英] Can't send emails with pyramid_mailer and gmail

查看:156
本文介绍了无法使用pyramid_mailer和gmail发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用我的gmail smtp和pyramid_mailer软件包从我的金字塔网站发送电子邮件。首先,如果有人对电子邮件解决方案有其他建议,请告诉我!



我在dev.ini中添加了以下内容:

  mail.host = smtp.gmail.com 
mail.username = user@gmail.com
mail.password =密码
mail.port = 465
mail.ssl = True

然后我'发送这样的消息:

  config.registry ['mailer'] = Mailer.from_settings(settings)

以后...

  mailer = request.registry ['mailer'] 
message = Message(subject =hello world,$ b $ sender =admin@mysite.com,
recipients = [ someaddress@gmail.com],
body =hello!)
mailer.send(message)

不幸的是,我得到以下异常:

  SMTPServerDisconnected:请运行connect()first 

我做错了什么?

谢谢!
<以下设置适用于我:

 #pyramid_mailer 
mail.host = smtp.gmail.com
mail.port = 587
mail.username = my.login@gmail.com
mail.password = mypassword
mail .tls = True

您的邮件发送代码似乎与我的一样,所以应该可以工作。



我还没有试过SSL,但我假设所有类型的bugaboos都可能存在thataway。


I am trying to send emails from my pyramid website with my gmail smtp and the pyramid_mailer package. First of all, if anyone has another suggestion for an email solution, please let me know!

I added the following to my dev.ini:

mail.host = smtp.gmail.com
mail.username = user@gmail.com
mail.password = password
mail.port = 465
mail.ssl = True

And then I'm sending the message like so:

config.registry['mailer'] = Mailer.from_settings(settings)

and later...

mailer = request.registry['mailer']
message = Message(subject="hello world",
                      sender="admin@mysite.com",
                      recipients=["someaddress@gmail.com"],
                      body="hello!")
mailer.send(message)

Unfortunately, I get the following exception:

SMTPServerDisconnected: please run connect() first

What am I doing wrong?

Thanks!

解决方案

The following settings worked for me:

# pyramid_mailer
mail.host = smtp.gmail.com
mail.port = 587
mail.username = my.login@gmail.com
mail.password = mypassword
mail.tls = True

Your mail sending code seems to be the same as mine, so that should work.

I haven't tried SSL, but I'm assuming that all kinds of bugaboos may exist thataway.

这篇关于无法使用pyramid_mailer和gmail发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆