I see many solutions but still, I have a problem for send mail and I also set email and password to ~/.bash_profile so please help me.
Here my connfig.py file code
import os
class Config:
SECRET_KEY=os.environ.get('SECRET_KEY')
SQLALCHEMY_DATABASE_URI=os.environ.get('SQLALCHEMY_DATABASE_URI')
MAIL_SERVER = 'smtp.googlemail.com'
MAIL_PORT = 465
MAIL_USE_SSL= True
MAIL_USERNAME=os.environ.get('EMAIL_USER')
MAIL_PASSWORD=os.environ.get('EMAIL_PASS')
I also try the google two-step verification and app password still I have a problem. What can I do now?
I had the same problem when I debugged my code I found that my os.environ.get('EMAIL_USER')
was empty. Make sure it has your exact credentials.
What I did was hardcoding my username and password (it is not recommended to do it for security purposes) :
class Config:
SECRET_KEY=os.environ.get('SECRET_KEY')
SQLALCHEMY_DATABASE_URI=os.environ.get('SQLALCHEMY_DATABASE_URI')
MAIL_SERVER = 'smtp.googlemail.com'
MAIL_PORT = 465
MAIL_USE_SSL= True
MAIL_USERNAME='youremailhere'
MAIL_PASSWORD='yourpasswordemailhere'
... and then make sure you have the Less Secure App Access turned on in your google account, you'll find it here -> https://myaccount.google.com/lesssecureapps