Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29745

Getting unauthorized sender address when using SMTPLib Python

$
0
0

I have a very simple Python script that I wrote to send out emails automatically. Here is the code for it:

import smtplib

From = "LorenzoTheGabenzo@gmx.com"
To = ["LorenzoTheGabenzo@gmx.com"]

with smtplib.SMTP('smtp.gmx.com', 587) as smtp:
    smtp.ehlo()
    smtp.starttls() 
    smtp.ehlo()

    smtp.login("LorenzoTheGabenzo@gmx.com", Password)

    Subject = "Test"
    Body = "TestingTheBesting"
    Message = f"{Subject}\n\n{Body}"

    smtp.sendmail(From, To, Message)

Whenever I run this code I get a very strange error telling me that this sender is an "unauthorized sender". Here is the error in full

File "test.py", line 17, in <module>    smtp.sendmail(From, To, Message)
  File "C:\Users\James\AppData\Local\Programs\Python\Python37-32\lib\smtplib.py", line 888, in sendmail888, in sendmail    raise SMTPDataError(code, resp)smtplib.SMTPDataError: (554, b'Transaction failed\nUnauthorized sender address.')

I've already enabled SMTP access in the GMX settings and I'm unsure about what else to do now to fix this issue.

Note: I know that the variable password has not been defined. This is because I intentionally removed it before posting, it's defined in my original code.


Viewing all articles
Browse latest Browse all 29745

Trending Articles