Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending E-mails
#1
Hello,
I am trying to just learn how to send e-mails with python. I have found some code online and I am trying to use it but an error keeps appearing. This is the code I am trying to use.
import smtplib

server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login("my_email", "my_password")
server.sendmail(
  "from_email", 
  "to_email", 
  "Test Message")
server.quit()
When I do this, this is what happens:
Output:
Traceback (most recent call last): File "C:\Users\keega\OneDrive\Documents\Python\Email Sender.py", line 4, in <module> server.login("k*************[email protected]", "K*****123") File "C:\Users\keega\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 730, in login raise last_exception File "C:\Users\keega\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 721, in login initial_response_ok=initial_response_ok) File "C:\Users\keega\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 642, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbua\n5.7.14 BWQcAmZiJozJSC9UqHf-MDmwIwlPfsh2QD_0n8TN8Lwr1Jx6EXt33UVEyOBgAXJHTNvnXX\n5.7.14 Y3yIr1HUR877awIHRkPYpljnbMIt6UpOK66N7MISLFL_qG-BHQNqFXGMcT23yQbMVDiugI\n5.7.14 yeBgR7_P84SEH-8MFZjQ38inz0tIJP8S1dB7yr2_4K6n-ONQdtxEGYV71D_FEyRzCzfNyL\n5.7.14 5l6psrK-kOCcl03uzz5HlxUWnjo80nJA_VXUCaCiBsuJLuRBjp> Please log in via\n5.7.14 your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 c68-v6sm18546669pfj.51 - gsmtp')
Does anyone know what is wrong and how to fix it?
Thanks :)
Reply
#2
This error is probably caused because Google blocks sign-in attempts from lesser secured apps. If you login to your gmail account you probably received also an email regarding a lesser secured app trying to sign in to your account?

If you want to turn off this safety feature you can do that here: https://www.google.com/settings/security/lesssecureapps
Reply
#3
Here's a troubleshooting guide that should work.

Most likely problem is of "Allowing less secure apps" Go to THIS link and allow less secure apps to login into the account.
Reply
#4
Hello Again,
Thank you it has worked. I already did this, but for some reason it didn't work but I did it again and now works fine.
Thank You Both
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python, sending E-mails Daxanius 1 2,799 Sep-05-2018, 03:49 PM
Last Post: buran
  Wrong or missing date format and time in mails sipriusPT 3 4,213 Aug-08-2017, 03:22 PM
Last Post: sipriusPT

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020