I am using simple python lib for the SMTP But i am getting this error:
import smtplib smtpObj = smtplib.SMTP('localhost') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/smtplib.py", line 249, in __init__ (code, msg) = self.connect(host, port) File "/usr/lib/python2.7/smtplib.py", line 309, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket return socket.create_connection((port, host), timeout) File "/usr/lib/python2.7/socket.py", line 571, in create_connection raise err socket.error: [Errno 111] Connection refused
Using python-2.7
What's Causing This Error. The SMTP 111 error occurs when an issue is present while connecting with the remote SMTP server. For example, you would run into this error due to invalid sender domains or firewall issues.
check from the server, if you're accepting the connections to the server: again based on your OS, but telnet LISTENING_IP LISTENING_PORT should do the job. check if you can access the port of the server from the client, but not using the code: just us the telnet (or appropriate command for your OS) from the client.
Start a simple SMTP server with Python like so:
python -m smtpd -n -c DebuggingServer localhost:1025
or you can also try gmail smtp setting
server = smtplib.SMTP(host='smtp.gmail.com', port=587)
if you:
python -m smtpd -n -c DebuggingServer localhost:1025
as suggested by Allen Thomas, then make sure you init:
server = smtplib.SMTP(host='localhost', port=1025)
with matching port number, here: 1025.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With