SMTPAuthentication error when sending confirmation email in Django - python

Getting the error message
SMTPAuthenticationError at /accounts/signup/teacher/ (530, b'Must
issue a STARTTLS command first')
when trying to test the signup process in my django app. What should happen is that a user who signs in should receive a confirmation email after signing up.
Here are my settings
EMAIL_BACKED = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mail.privateemail.com'
EMAIL_PORT = 587
EMAIL_USER_TLS = True
EMAIL_HOST_USER = '***#***.com'
EMAIL_HOST_PASSWORD = '***'
I am using privateemail from namecheap to send the confirmation emails

Related

How to solve SMTNotSupported extension by the server Error?

Actually i am creating a registration form using django and when user will submit it he will get successful registration mail but it will give me error SMTPNotSupported extension server.
my settings.py file
EMAIL_HOST = 'smpt.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = myusername
EMAIL_HOST_PASSWORD = my password
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend
I am sharing my error photo with you all.

Error in sending email using gmail smtp in Django app

I set up everything as the Django documentation but when I test sending an email.It works but When I check my inbox I find out that I sent and revived from to the same email address.
Here is the settings.py
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = "myemail#gmail.com"
EMAIL_HOST_PASSWORD = "mypassword"
And the views.py
...
send_mail( 'subject', 'message', 'user#gmail.com', ['myemail#gmail.com',], fail_silently=False, )
...
But I received an email from myemail#gmail.com to me(myemail#gmail.com).
Im not sure if you did this already but if youre using gmail then you will need to do the following.
Sign in to your Google Admin console (Sign in using an administrator account)
Click Security > Less secure apps.
Select Allow users to manage their access to less secure apps.
Click Save.25
Also you should use environment variables for the email address if you are live already eg:
EMAIL_HOST_USER = os.environ.get('MY_EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('MY_EMAIL_PASS')
If its all working and you are just getting the mail to the wrong address can you send on the document you followed?
In terms of you settings.py that looks fine to me.

google SMTP is giving error on sending mail

I am using python Django to send mail to a user when user login and using django.core.mail(send mail) but it's working on localhost and successfully sending emails to the user but when I host my site on Heroku it's giving some errors.
settings.py
# email config
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # During deployment only
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = 587
EMAIL_HOST_USER = config('EMAIL_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_USER_PASSWORD')
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Masjid Matrimonial Team <noreply#example.com>'
Views.py
currenttime=datetime.now()
subject = "New Login Alert"
message="You have loged into your account on "+ currenttime.strftime('%A %d %B,%Y %I:%M %p')
recipient_list = [useris.appuser.email]
send_mail( subject, message, email_from, recipient_list )email_from = settings.EMAIL_HOST_USER
SMTP Error code 534 5.7.14 means Authorization error.
Try to activate sending via less secure apps via https://myaccount.google.com/lesssecureapps

Sending Email with Django

I'm trying to send email with django. Here's my settings.py file.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'mymail#gmail.com'
EMAIL_HOST_PASSWORD = 'mailpassword'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'mymail#gmail.com'
I've also enabled access to less secure apps in the gmail settings.
On the production server whenever I try to send an email, it's raising an error in the command line upstream prematurely closed connection while reading response header from upstream.
On webpage it's showing 502 Bad Gateway error.
How can we solve this issue? Thank You . . .

Django SMTP Error: authentication failed: authentication failure

I set up django email backend following way:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# Host for sending e-mail.
EMAIL_HOST = 'mytdl.de'
# Port for sending e-mail.
EMAIL_PORT = 25
# Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER = 'me#mytdl.de'
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
But sending emails with django-allauth will return following error:
(535, b'5.7.8 Error: authentication failed: authentication failure')
Testing the the settings with
telnet mytdl.de 25
or Thunderbird as email client works fine.
2.7.0 Authentication successful
But Django / SMTP stills throws that error.
Django also tries to
AUTH CRAM-MD5
and not
AUTH LOGIN
any ideas?
If your email host is gmail then you can fix it with these simple steps:
Login to your gmail account (The one you are using in your Django application for sending mails ).
Then select Account from google apps or click here.
On your control panel click on Apps with account access under Sign-in & security.
Then scroll down and enable Allow less secure apps
Also maintain your settings variables in this order:
settings.py
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'example#gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587

Categories