如何使用 Python 和 Flask 发送电子邮件

编程入门 行业动态 更新时间:2024-10-27 01:20:38
本文介绍了如何使用 Python 和 Flask 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我现在正在我的网站上工作,并尝试在用户创建帐户时发送确认电子邮件.我怎样才能在 Python 中做到这一点?我什至可以在我的 Flask 应用程序上用 Python 来做吗?我现在真的很困惑,可以使用一些帮助.非常感谢大家:)

I am working on my website right now and am trying to send a confirmation email when a user creates an account. How can I do this in Python? Can I even do it in Python on my Flask app? I'm really confused right now and could just use some help. Thank you all so much :)

推荐答案

您可以使用 flask_mail为此目的

要使其工作,请以这种方式设置参数:

To make it work set parameters this way:

app.config['MAIL_SERVER'] = 'smtp.gmail'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'youremail@gmail' # your email
app.config['MAIL_PASSWORD'] = 'your-password' # your password

同时转到您的谷歌帐户安全设置并启用不太安全的应用访问",但谷歌并不真正喜欢它,有时你仍然会出错.在这种情况下,只需尝试使用解冻设置,关闭并再次打开,在某些时候它肯定会起作用(我非常确信,因为这对我完全有用)

Also go to your google account security settings and enable 'Less secure app access’, but google doesn’t really like it and still sometimes you can get errors. In this case just try to play with thaws settings, turn things off and on again, at some point it should definitely work (I’m so convinced, cause this totally works for me)

您也可以在谷歌设置中使用应用专用密码.

You also can use the app-specific password in google settings.

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

更多推荐

[db:关键词]

本文发布于:2023-04-26 17:26:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1139263.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   发送电子邮件   Python   Flask

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!