Error Message "SMTPAuthenticationError",how to correct the python code??

Erwin 26 Reputation points
2023-02-08T03:45:22.1733333+00:00

Use python to send email ,but display error message "SMTPAuthenticationError",

how to correct the python code??

*p.s. sender's mail will not from Gmail...

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,364 questions
0 comments No comments
{count} votes

Accepted answer
  1. Arun Siripuram 801 Reputation points
    2023-02-08T06:08:27.53+00:00

    The error "SMTPAuthenticationError" usually occurs when the email client (in this case, python) is unable to authenticate with the mail server using the provided credentials (username and password).

    To correct the python code, you'll need to make sure that the credentials are correct and also check if the mail server requires any specific authentication method (e.g. TLS or SSL).

    Here's an example of how you can send an email using Python's smtplib library:

    Sample Code looks like this below.

    import smtplib

    sender_email = "sender@example.com"

    receiver_email = "receiver@example.com"

    password = "password"

    message = """\

    Subject: Hi there

    This message is sent from Python."""

    server = smtplib.SMTP('smtp.example.com', 587)

    server.ehlo()

    server.starttls()

    server.login(sender_email, password)

    server.sendmail(sender_email, receiver_email, message)

    server.quit()

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful