Skip to content Skip to sidebar Skip to footer

Smtplib Of Python Not Working

Trying to connect to smpt server of gmail but it is giving network unreachable import smtplib s=smtplib.SMTP('smtp.gmail.com',587) Neither this is working import smtplib s=smtpli

Solution 1:

Use port 465. From Google docs on SMTP configuration;

enter image description here

importsmtplibs= smtplib.SMTP_SSL('smtp.gmail.com', 465)

Solution 2:

According to this page port 587 requires TLS.

Solution 3:

For me when i tried in Ubuntu it is working with TLS port. Script is shown here:

importsmtplibserver= smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()

and it is working with SSL port in windows cygwin. Script is shown here:

importsmtplibserver= smtplib.SMTP_SSL('smtp.gmail.com', 465)

Solution 4:

For me, it was because the network had dissallowed opening of sockets, try a different network if possible

Post a Comment for "Smtplib Of Python Not Working"