I want to use two email, one for verifying the email and other for sending normal informative emails. I am able to send email for verification with the following code and I want to use my another email for that second perpose.
views.py
current_site = get_current_site(request)
subject = 'Welcome to MySite! Confirm Your email.'
htmly = get_template('account_activation_email.html')
d = { 'user': user, 'domain':current_site.domain, 'uemail':urlsafe_base64_encode(force_bytes(user.email)), 'uid':urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user)}
text_content = ""
html_content = htmly.render(d)
msg = EmailMultiAlternatives(subject, text_content, '', [user.email])
msg.attach_alternative(html_content, "text/html")
try:
msg.send()
except BadHeaderError:
print("Error while sending email!")
user.save()
and in settings:
EMAIL_USE_TLS = True
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_HOST_USER = verify@mysite.com
EMAIL_HOST_PASSWORD = 'randompass'
EMAIL_PORT = config('EMAIL_PORT')
DEFAULT_FROM_EMAIL = 'MySte Verification <verify@mysite.com>'
Please help!!!