SMTP Library with Custom Domains for Python

60 Views Asked by At

I'm trying to log into the SMTP server. The custom domain is not able to be recognized through the smtplib.SMTP host parameter.

Have Tried:

SMTP host for gmail domains

    # login smtp server
    # Issue
    server = smtplib.SMTP(host="smtp.gmail.com", port=587)
    #

    print(server)
    server.ehlo()
    server.starttls()
    print(username, email, app_password)
    server.login(username, app_password)
    print("logged in")
    server.sendmail(from_email, to_emails, msg_str)
    server.quit()

Not Working:

SMTP host for custom domain

    # login smtp server
    # Issue
    server = smtplib.SMTP(host="smtp.customDomain.io", port=587)
    #

    print(server)
    server.ehlo()
    server.starttls()
    print(username, email, app_password)
    server.login(username, app_password)
    print("logged in")
    server.sendmail(from_email, to_emails, msg_str)
    server.quit()
0

There are 0 best solutions below