hakermania
May 13th, 2010, 08:17 PM
I had this script
#!/usr/bin/python
import smtplib
SERVER = "localhost"
FROM = "example@gmail.com"
TO = ["example@hotmail.com"] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
# Prepare actual message
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send the mail
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message)
server.quit()
And it has these errors:
Traceback (most recent call last):
File "./sntmleil.py", line 25, in <module>
server = smtplib.SMTP(SERVER)
File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.6/smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
File "/usr/lib/python2.6/socket.py", line 514, in create_connection
raise error, msg
socket.error: [Errno 111] Connection refused
And I find it logical because I normally have to declare a password or something for gmail. Can you actually tell me how can i make a script like this which works?
#!/usr/bin/python
import smtplib
SERVER = "localhost"
FROM = "example@gmail.com"
TO = ["example@hotmail.com"] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
# Prepare actual message
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send the mail
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message)
server.quit()
And it has these errors:
Traceback (most recent call last):
File "./sntmleil.py", line 25, in <module>
server = smtplib.SMTP(SERVER)
File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.6/smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
File "/usr/lib/python2.6/socket.py", line 514, in create_connection
raise error, msg
socket.error: [Errno 111] Connection refused
And I find it logical because I normally have to declare a password or something for gmail. Can you actually tell me how can i make a script like this which works?