Reputation: 31
The project is to be able to send email from within Python. I can successfully send to, for example, "smtp.gmail.com", but using a localhost or 127.0.0.1 returns an "errno 111, connection was refused." The statement is
server = smtplib.SMTP('127.0.0.1', 8025)
Notes: I am running Ubuntu, Python 3.2 or Python 2.7 depending on what the wonderful people here know best, and my programming knowledge could be charitably described as limited.
Upvotes: 3
Views: 6919
Reputation: 708
What you're attempting to do, is using the local machine as the smtp-server. The simplest way to achieve this in Ubuntu, would be to install one of the exim4 or postfix-packages in apt / synaptic ...
Make sure that when prompted, that you don't allow machines you don't trust to use your host as a mail-relay. The defaults should be sufficient to avoid this - yet still allow mail to be sent from your machine.
Also note that the default port-number for smtp is port 25, and not 8025 as in your code example.
Upvotes: 1
Reputation: 35562
First, test your local SMTP connection using Telnet. (Alternate instructions here) This will tell if you can connect to your local SMTP server in the way you think you can.
You probably have one of several problems:
Python SMTPlib supports authorized connections using LMTP for issue 2.
Try using port 25 for issue 5.
For the other issues, you will need to find or setup a cooperative SMTP server.
BTW: properly configuring and securing an SMTP server is not trivial...
Upvotes: 1