[GH-ISSUE #494] smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful') #364

Closed
opened 2026-02-25 23:42:11 +03:00 by kerem · 16 comments
Owner

Originally created by @technobasant on GitHub (Mar 13, 2021).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/494

Unable to a sent email from the application:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "./hc/lib/emails.py", line 28, in run
msg.send()
File "/usr/local/lib/python3.9/site-packages/django/core/mail/message.py", line 284, in send
return self.get_connection(fail_silently).send_messages([self])
File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
new_conn_created = self.open()
File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 69, in open
self.connection.login(self.username, self.password)
File "/usr/local/lib/python3.9/smtplib.py", line 734, in login
raise last_exception
File "/usr/local/lib/python3.9/smtplib.py", line 723, in login
(code, resp) = self.auth(
File "/usr/local/lib/python3.9/smtplib.py", line 646, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful')

Originally created by @technobasant on GitHub (Mar 13, 2021). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/494 Unable to a sent email from the application: Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "./hc/lib/emails.py", line 28, in run msg.send() File "/usr/local/lib/python3.9/site-packages/django/core/mail/message.py", line 284, in send return self.get_connection(fail_silently).send_messages([self]) File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages new_conn_created = self.open() File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 69, in open self.connection.login(self.username, self.password) File "/usr/local/lib/python3.9/smtplib.py", line 734, in login raise last_exception File "/usr/local/lib/python3.9/smtplib.py", line 723, in login (code, resp) = self.auth( File "/usr/local/lib/python3.9/smtplib.py", line 646, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful')
kerem closed this issue 2026-02-25 23:42:11 +03:00
Author
Owner

@cuu508 commented on GitHub (Mar 15, 2021):

Have you checked your SMTP credentials (host, port, username, password) are correct?

<!-- gh-comment-id:799208830 --> @cuu508 commented on GitHub (Mar 15, 2021): Have you checked your SMTP credentials (host, port, username, password) are correct?
Author
Owner

@technobasant commented on GitHub (Mar 21, 2021):

@cuu508
Yeah, I have double checked everything, Still got the error, I was able to connect Gmail server using the below settings ENVs on settings.py though,
SMTP credentials for sending email
EMAIL_HOST = os.getenv("EMAIL_HOST", ""e
EMAIL_PORT = envint("EMAIL_PORT", "587")
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER", "")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD", "")
EMAIL_USE_TLS = envbool("EMAIL_USE_TLS", "True")
EMAIL_USE_VERIFICATION = envbool("EMAIL_USE_VERIFICATION", "True")

The problem still exists, I was unable to set email server using ENV variables and got an above-mentioned error. This seems like Django isseue

<!-- gh-comment-id:803553911 --> @technobasant commented on GitHub (Mar 21, 2021): @cuu508 Yeah, I have double checked everything, Still got the error, I was able to connect Gmail server using the below settings ENVs on settings.py though, SMTP credentials for sending email EMAIL_HOST = os.getenv("EMAIL_HOST", ""e EMAIL_PORT = envint("EMAIL_PORT", "587") EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER", "") EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD", "") EMAIL_USE_TLS = envbool("EMAIL_USE_TLS", "True") EMAIL_USE_VERIFICATION = envbool("EMAIL_USE_VERIFICATION", "True") The problem still exists, I was unable to set email server using ENV variables and got an above-mentioned error. This seems like Django isseue
Author
Owner

@cuu508 commented on GitHub (Mar 21, 2021):

I was able to connect Gmail server using the below settings ENVs

So, problem solved?

<!-- gh-comment-id:803554350 --> @cuu508 commented on GitHub (Mar 21, 2021): > I was able to connect Gmail server using the below settings ENVs So, problem solved?
Author
Owner

@technobasant commented on GitHub (Mar 21, 2021):

@cuu508
I want to set up a separate dedicated mail server for this app and it failed, I was testing with a Gmail account, and its works, I am still not sure why the Auth error is thrown when I can log in with the same credentials?

<!-- gh-comment-id:803554747 --> @technobasant commented on GitHub (Mar 21, 2021): @cuu508 I want to set up a separate dedicated mail server for this app and it failed, I was testing with a Gmail account, and its works, I am still not sure why the Auth error is thrown when I can log in with the same credentials?
Author
Owner

@cuu508 commented on GitHub (Mar 21, 2021):

Have you checked the SMTP (not POP3, not IMAP) credentials with a different client, and they work?

If you're using port 25, have you checked port 25 is not blocked?

<!-- gh-comment-id:803559149 --> @cuu508 commented on GitHub (Mar 21, 2021): Have you checked the SMTP (not POP3, not IMAP) credentials with a different client, and they work? If you're using port 25, have you checked port 25 is not blocked?
Author
Owner

@technobasant commented on GitHub (Mar 21, 2021):

@cuu508
As for the port its open, that's not the issue, POP3 and IMAP I have to test it but I am confident that I am using SMPT credentials..

<!-- gh-comment-id:803562625 --> @technobasant commented on GitHub (Mar 21, 2021): @cuu508 As for the port its open, that's not the issue, POP3 and IMAP I have to test it but I am confident that I am using SMPT credentials..
Author
Owner

@cuu508 commented on GitHub (Mar 21, 2021):

Verify the SMTP credentials work with a different client. If you configure, say, Thunderbird, to send email through your SMTP server, does it work?

On residential and even some datacenter locations the port 25 may be blocked by the ISP.

<!-- gh-comment-id:803563839 --> @cuu508 commented on GitHub (Mar 21, 2021): Verify the SMTP credentials work with a different client. If you configure, say, Thunderbird, to send email through your SMTP server, does it work? On residential and even some datacenter locations the port 25 may be blocked by the ISP.
Author
Owner

@gelodefaultbrain commented on GitHub (Jan 24, 2022):

It's so weird, when I tried this code on my COMPUTER it worked

def send_email(sender,sender_pass,receiver,mail_content,subject):
	'''Parameters are already some of the needed data'''

	#Setup the MIME
	message = MIMEMultipart()

	message['From'] = sender
	message['To'] = receiver
	message['Subject'] = subject

	message.attach(MIMEText(mail_content, 'plain'))

	#Create SMTP session for sending the mail
	session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port
	session.starttls() #enable security
	session.login(sender, sender_pass) #login with mail_id and password
	text = message.as_string()
	session.sendmail(sender, receiver, text)
	session.quit()
	print('Mail Sent')

but if I tried to run it on a server based from the UK it doesn't work

<!-- gh-comment-id:1019749550 --> @gelodefaultbrain commented on GitHub (Jan 24, 2022): It's so weird, when I tried this code on my COMPUTER it worked ``` def send_email(sender,sender_pass,receiver,mail_content,subject): '''Parameters are already some of the needed data''' #Setup the MIME message = MIMEMultipart() message['From'] = sender message['To'] = receiver message['Subject'] = subject message.attach(MIMEText(mail_content, 'plain')) #Create SMTP session for sending the mail session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port session.starttls() #enable security session.login(sender, sender_pass) #login with mail_id and password text = message.as_string() session.sendmail(sender, receiver, text) session.quit() print('Mail Sent') ``` but if I tried to run it on a server based from the UK it doesn't work
Author
Owner

@aarshcode commented on GitHub (Apr 1, 2023):

Were you able to solve the problem?

I am also facing the same problem. On my own system, I am able to execute the send mail script but on GitHub actions, it gives me an authentication error.

smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful [BN9PR03CA0842.namprd03.prod.outlook.com 2023-04-01T21:04:20.945Z 08DB30BAD36F4CE5]')
<!-- gh-comment-id:1493127497 --> @aarshcode commented on GitHub (Apr 1, 2023): Were you able to solve the problem? I am also facing the same problem. On my own system, I am able to execute the send mail script but on GitHub actions, it gives me an authentication error. ``` smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful [BN9PR03CA0842.namprd03.prod.outlook.com 2023-04-01T21:04:20.945Z 08DB30BAD36F4CE5]') ```
Author
Owner

@cuu508 commented on GitHub (Apr 3, 2023):

@aarshcode I don't think this is a Healthchecks-specific problem. You should check Github docs and/or Github support to see if sending emails from GHA is allowed, and what ports and what protocols are allowed.

<!-- gh-comment-id:1493931674 --> @cuu508 commented on GitHub (Apr 3, 2023): @aarshcode I don't think this is a Healthchecks-specific problem. You should check Github docs and/or Github support to see if sending emails from GHA is allowed, and what ports and what protocols are allowed.
Author
Owner

@harshd3001 commented on GitHub (Jul 24, 2023):

I'm facing the same issue can someone help me with this
it should me this error when i trying loging in gmail with smtp
(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials f9-20020a170902e98900b001bb892a7a67sm5003108plb.1 - gsmtp')

my email and app password is correct the script runs fine when i run it in my computer but in workflow actions it is giving this error.

<!-- gh-comment-id:1648445143 --> @harshd3001 commented on GitHub (Jul 24, 2023): I'm facing the same issue can someone help me with this it should me this error when i trying loging in gmail with smtp (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials f9-20020a170902e98900b001bb892a7a67sm5003108plb.1 - gsmtp') my email and app password is correct the script runs fine when i run it in my computer but in workflow actions it is giving this error.
Author
Owner

@cuu508 commented on GitHub (Jul 28, 2023):

@harshd3001 You should check Github docs and/or Github support to see if sending emails from GHA is allowed, and what ports and what protocols are allowed.

<!-- gh-comment-id:1655215769 --> @cuu508 commented on GitHub (Jul 28, 2023): @harshd3001 You should check Github docs and/or Github support to see if sending emails from GHA is allowed, and what ports and what protocols are allowed.
Author
Owner

@Doyewole69 commented on GitHub (Mar 26, 2024):

I'm facing the same issue can someone help me with this it should me this error when i trying loging in gmail with smtp (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials f9-20020a170902e98900b001bb892a7a67sm5003108plb.1 - gsmtp')

my email and app password is correct the script runs fine when i run it in my computer but in workflow actions it is giving this error.

you should create an app password on your gmail account that should solve the problem

<!-- gh-comment-id:2020296150 --> @Doyewole69 commented on GitHub (Mar 26, 2024): > I'm facing the same issue can someone help me with this it should me this error when i trying loging in gmail with smtp (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials f9-20020a170902e98900b001bb892a7a67sm5003108plb.1 - gsmtp') > > my email and app password is correct the script runs fine when i run it in my computer but in workflow actions it is giving this error. you should create an app password on your gmail account that should solve the problem
Author
Owner

@linuxd3v commented on GitHub (May 13, 2024):

When I had this error - It turned out to be that updating the docker-compose smtp settings just wasnt enough, because real smtp configuration was stored in local_settings.py.
I think healthchecks populates the local_settings.py smtp config on container start, but if you updated the docker container smtp env varibles - it doesnt actually update the local_settings.py.
which was the problem in my case - I just had to update the smtp settings in local_settings.py.

<!-- gh-comment-id:2107518907 --> @linuxd3v commented on GitHub (May 13, 2024): When I had this error - It turned out to be that updating the docker-compose smtp settings just wasnt enough, because real smtp configuration was stored in local_settings.py. I think healthchecks populates the local_settings.py smtp config on container start, but if you updated the docker container smtp env varibles - it doesnt actually update the local_settings.py. which was the problem in my case - I just had to update the smtp settings in local_settings.py.
Author
Owner

@cuu508 commented on GitHub (May 16, 2024):

@linuxd3v were you using the linuxserver image by any chance?

The healthchecks official image does not write local_settings.py and always uses the environment variables that are passed in.

<!-- gh-comment-id:2115635448 --> @cuu508 commented on GitHub (May 16, 2024): @linuxd3v were you using the linuxserver image by any chance? The [healthchecks official image](https://hub.docker.com/r/healthchecks/healthchecks) does not write local_settings.py and always uses the environment variables that are passed in.
Author
Owner

@linuxd3v commented on GitHub (May 16, 2024):

@cuu508 yes - I'm using the linuxserver/healthchecks.
I think when I started using healthchecks (it's been several years) - the official healthchecks/healthchecks image might not have been available yet.

<!-- gh-comment-id:2115649870 --> @linuxd3v commented on GitHub (May 16, 2024): @cuu508 yes - I'm using the [linuxserver/healthchecks](https://hub.docker.com/r/linuxserver/healthchecks). I think when I started using healthchecks (it's been several years) - the official [healthchecks/healthchecks](https://hub.docker.com/r/linuxserver/healthchecks) image might not have been available yet.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#364
No description provided.