I am trying to sending auto mail from my real mail adres to other mail adres. I use my real password for MAIL_PASSWORD value. What am I doing wrong with coding. I dont get any errors but I dont get any mails neihter... I need help to figure it out.
from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
mail= Mail(app)
app.config['MAIL_SERVER']='smtp.gmail.com' #or localhost what is the difference between localhost and smtp I dont know yet
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'mymail@gmail.com'
app.config['MAIL_PASSWORD'] = 'realmailpassword'
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
@app.route("/")
def index():
try:
msg = Message('Hello',
sender='mymail@gmail.com',
recipients='receiver@gmail.com')
msg.body = 'my first auto mail'
mail.send(msg)
print('mail has been sent')
except Exception:
print('mail could not be send')
if __name__ == '__main__':
app.run(debug = True)