I have separate django project and one python script file. The script file will not depends on project(that was available in different path).
The script file will generate some data and need to send mail to corresponding user. In this case i am trying to use django mail:-
from django.core.mail import EmailMessage, SMTPConnection
I enabled the django environment in my python script file and added the sys.path to my django project settings(So i can able to use django mail).
# setting a django environment
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
sys.path = sys.path + [PROJECT_PATH]
And the mail config code added in my script:-
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'xxx'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
After all this mail not working properly. Because the above parameters not in settings file(The actual problem is if i added this "EMAIL_USE_TLS" parameter itself in settings means it works properly other parameters taking from my script file.
My question is why "EMAIL_USE_TLS" this parameter is not taking from my script file like other parameters?
or
Is mandatory one "EMAIL_USE_TLS" this needs to specify in settings file?
If i not specified EMAIL_USE_TLS = True in settings means got below error:-
SMTP AUTH extension not supported by server
Please anyone advise on this.