I'm trying to send a email for users. In one situation it sends, but in other didn't send. If I use 'email_user' it sends the email. 'user' is an autentificated user (built in with django). About 'send_mail' I know after reading the documentation.
current_site = get_current_site(request)
subject = 'Activate Your Account'
message = render_to_string('account_activation_email.html', {
'user': user,
'domain': current_site.domain,
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'token': account_activation_token.make_token(user),
})
user.email_user(subject, message)
return redirect('account_activation_sent')
But when I want to use send_mail instead of email_user, it's not working. I want to understand what I do wrong.
send_mail(subject, message, email_from, recipient_list, fail_silently=False)
My settings:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL = get_secret('EMAIL_HOST_USER')
EMAIL_HOST = get_secret('EMAIL_HOST')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = get_secret('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = get_secret('EMAIL_HOST_PASSWORD')
# Custom setting. To email
RECIPIENT_ADDRESS = ['None']