settings.py : DEFAULT_FROM_EMAIL = '*****************'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = '
smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = ***
EMAIL_HOST_USER = '*********************"
EMAIL_HOST_PASSWORD = '***********"
script.py :
from_email = DEFAULT_FROM_EMAIL
vars_dict = dict(tasks=usr_tasks,
reminder=reminder,
reseller=reseller,
logo=logo,
host=host,
)
# get values: r_email and r_pass specific to this reseller
r_obj = Reseller.objects.get(id=rid)
r_email = r_obj.remail if r_obj.remail else None
r_pass = r_obj.rpass if r_obj.rpass else None
html_message = loader.render_to_string(
template,vars_dict)
if subject and message and from_email:
print("Sending mail to %s"%recipient)
try:
if r_email and r_pass:
send_mail(subject,message,from_email,recipient,fail_silently=True, EMAIL_HOST_USER=r_email,
EMAIL_HOST_PASSWORD=r_pass, html_message=html_message)
else:
send_mail(subject,message,from_email,recipient,fail_silently=True,html_message=html_message)
except Exception as e:
print(e)
else:
print("Mail sent successfully!")
---------------------------------------------------------------------------------------------------------------------------------
Roughly this is my code.
in line - send_mail(subject,message,from_email,recipient,fail_silently=True, EMAIL_HOST_USER=r_email,
EMAIL_HOST_PASSWORD=r_pass, html_message=html_message)
its giving me error - send_mail() got an unexpected keyword argument 'EMAIL_HOST_USER'
Can you suggest anything about this ?
Thanks