It's more likely that google is not accepting the credentials you are providing or else the smtp server has just hung up due to several requests.
You can do it without using the django.core.mail. I've written an article recently on dev.to
Follow up and hope the article helps you
Thanks and Regards
Lakshyaraj Dash
On Wed, Nov 9, 2022 at 4:25 PM peteru mimo <peterumimo2@gmail.com> wrote:
Good day team,I have been facing this challenge in sending mail in djangohere is the error "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"Codedef send_verification_email(request, user):from_email = settings.DEFAULT_FROM_EMAILcurrent_site = get_current_site(request)mail_subject = 'Please activate your account'message = render_to_string('accounts/emails/account_verification_email.html', {'user': user,'domain': current_site,'uid': urlsafe_base64_encode(force_bytes(user.pk)),'token': default_token_generator.make_token(user),})to_email = user.emailmail = EmailMessage(mail_subject, from_email, message, to=[to_email])mail.send()SettingsEMAIL_HOST = 'smtp.google.com'EMAIL_POST = '587'EMAIL_HOST_USER = 'myemail'EMAIL_HOST_PASSWORD = 'email_password'EMAIL_USE_TLS = TrueAny solution will be appreciated. Thank you--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1ed5b9fc-3370-413c-b4cb-edeb2451d8f4n%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF7qQgDsWQiDUyYuxNHDz5%2BWteJ%3DMF_6VbtrYoAQo_v4KhEjPA%40mail.gmail.com.
No comments:
Post a Comment