I already have code for sending e-mails with python:
def send_email_gmail(subject, message, destination):
""" Send an e-mail using gmail with message to destination email.
Arguments:
message {str} -- message string to send.
destination {str} -- destination email (as string)
"""
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
# not a real email account nor password, its all ok!
server.login('me123@gmail.com', 'fakepassword111!!!')
# craft message
msg = EmailMessage()
message = f'{message}\n'
msg.set_content(message)
msg['Subject'] = subject
msg['From'] = 'me123@gmail.com'
msg['To'] = destination
# send msg
server.send_message(msg)
and I've read the multiple question (Login credentials not working with Gmail SMTP or SMTPAuthenticationError when sending mail using gmail and python) solving the common error:
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sadfdgjsfgrp=1&dsfgscc=1dsdfgsfg&pldsfgt=AKsdfsdfggsdfggnsbu\n5.7.14 G0crCr0qSvWTng9xRE_pd3WnK3S2sDMsdfgsdfgX0J-xoetn7aHyFQi2qYrQisdfgsdfgKIwMCcgD7zLB1t7Z\n5.7.14 -OjHjpJqasdftBuTi9wh0sYlNW637SmPLuMnnLGn_WcZX5TGH4sddsfgXYar-Aasdfw0ctWfLhasdffPQV>\n5.7.14 Please log in via your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/787521345364524 n21sm17577sadfdsf46qtn.17 - gsmtp')
Anyway, I did what those answers suggest but I am still getting an error. So I decided I do not want to use gmail anymore for this. I am sending email from a fake account just for sending emails so the security for it doesn't matter to me.
So how do change the code above so that it works for a different emailing service that is more reliable for sending emails in python/code?
The idea answer would contain be self contained and contain a sample script that works.
Edit1:
I've of course check to turn on less secure app feature on my fake gmail, copy paste text of what that page says:
Turn off less secure app access
Your account is vulnerable to malicious activity because you’re allowing apps & devices that use less secure sign-in technology to access your account. You should turn off this type of access. Google will automatically turn this setting OFF if it’s not being used. Learn more
there is also a yellow exclamation sign warning me.
Edit2
Output of EmailMessage()
:
it as suggested I paste this (empty message).