Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29904

error in connecting to a smtp server with python

$
0
0

import smtplib

SERVER = "my.smtp.server.com"

FROM = "myemail@somehost.ca" TO = ["someemail@somehost.mun.ca"] # must be a list

SUBJECT = "Hello!"

TEXT = "hello"

Here is my code:

# Prepare actual message

message = """\
From: %s
To: %s
Subject: %s

%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)

# Send the mail

server = smtplib.SMTP(SERVER)
server.login('loginname','password') 

and this is the error I get:

Traceback (most recent call last):
File "C:\Documents and Settings\Desktop\New Text Document.py", line 24, in ?
server = smtplib.SMTP(SERVER)
  File "C:\Python24\lib\smtplib.py", line 241, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Python24\lib\smtplib.py", line 289, in connect
    for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
gaierror: (11001, 'getaddrinfo failed')

what do I do next?


Viewing all articles
Browse latest Browse all 29904

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>