smtp = smtplib.SMTP_SSL(SMTP_MAILSERVER)
        smtp.login(SMTP_USER,SMTP_PASSWORD)
        toaddrs = [send_to] + carboncopies
        smtp.sendmail(send_from, toaddrs, msg.as_string())
        smtp.close()

works for me. The mail server is siteground (https://www.siteground.co.uk/); could the issue is that your mail server (ionos) maybe doesn't support user/password authentication (e.g. only supports OAUTH2 etc... ???)

On 14/08/2024 18:08, Graeme Gemmill wrote:
In order to confirm an action, I create an email message within a Python
Script that is considered junk by Outlook 365, using

s = smtplib.SMTP('localhost')

s.send_message(msg)

s.quit()

This works.

To prevent the "junk" categorisation,  I therefore tried to use my 1and1
account as follows:

sender = 'gra...@gemmill.name'

addressee = sender

smtpaddr = 'smtp.ionos.co.uk'

port = 465

passwd = '*********' (deleted, known to be correct)

…….

with smtplib.SMTP_SSL(smtpaddr, port, context=context) as smtp:

smtp.login(sender, passwd)

smtp.send_message(msg)

(SORRY - indentation problem....)

This results in an error

smtplib.SMTPAuthenticationError: (535, b'Authentication credentials
invalid')

The same error message is given when I use a gmail.com account. In both
cases I know the password and username are correct

Can you help solve the problem please?

Thanks

--
 Next meeting: Online, Jitsi, Tuesday, 2024-09-03 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  https://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to