gpt4 book ai didi

python - 从 python webapp2 Google App Engine 发送电子邮件

转载 作者:行者123 更新时间:2023-11-28 19:12:09 25 4
gpt4 key购买 nike

我正在尝试从我的应用程序发送电子邮件。代码成功运行,没有错误。但它不发送电子邮件。它在控制台上显示此消息。

You are not currently sending out real email. 
If you have sendmail installed you can use it by using the
server with --enable_sendmail

google提供的示例代码是:

message = mail.EmailMessage(
sender="shaizi9687@gmail.com",
subject="Your account has been approved")

message.to = "ABC <shahzebakram@hotmail.com>"
message.body = """Dear Albert:
Your example.com account has been approved. You can now visit
http://www.example.com/ and sign in using your Google Account to
access new features.
Please let us know if you have any questions.
The example.com Team
"""
message.send()

最佳答案

那是因为默认情况下 dev_appserver 不会发送真实邮件。

电子邮件发送将在您推送到实时服务器时起作用,例如:

appcfg update /path/to/app/

但就像错误消息指出的那样,如果您的系统上安装了 sendmail 或使用 smtp 标志,则必须使用 --enable_sendmail 标志,例如:

dev_appserver /path/to/app/ --enable_sendmail=yes

或另一个例如使用 gmail 作为 smtp 提供商

dev_appserver /path/to/app --smtp_host=smtp.gmail.com --smtp_port=465 \
--smtp_user=user@gmail.com --smtp_password=password

更多解释在这里:https://cloud.google.com/appengine/docs/python/mail/

Mail and the development server

The development server can be configured to send email messages directly from your computer when you test a feature of your app that sends messages. You can configure the development server to use an SMTP server of your choice. Alternatively, you can tell the development server to use Sendmail, if Sendmail is installed on your computer and set up for sending email.

If you do not configure an SMTP server or enable Sendmail, when your app calls the Mail service, the development server will log the contents of the message. The message will not actually be sent.

关于python - 从 python webapp2 Google App Engine 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38671257/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com