简体   繁体   中英

How to send email from my own server using python


from flask import Flask
from flask_mail import Mail, Message
import os

app = Flask(__name__)

mail_settings = {
    "MAIL_SERVER": 'mail.hi.in',
    "MAIL_PORT": 465,
    "MAIL_USE_TLS": False,
    "MAIL_USE_SSL": True,
    "MAIL_USERNAME": abcde,
    "MAIL_PASSWORD": password
}

app.config.update(mail_settings)
mail = Mail(app)


if __name__ == '__main__':
    with app.app_context():
        msg = Message(subject="Hello",
                      sender=app.config.get("support@hi.in"),
                      recipients=["dfjhnk@gmail.com"],
                      body="This is a test email I sent with Gmail and Python!")
        mail.send(msg)


Error Saying: TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

This is a test email I sent with Gmail and Python, I see that you use Gmail, so if you don't have enabled "Less secure apps on your google account" go here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM