0

So I have this Python send-email file that sends an email (the text from a file) to a recipient specified inside the code:

import smtplib
from email.mime.text import MIMEText
msgContent = open(Sourcefilelocation, "rb")
msg = MIMEText(spam.read())
msgContent.close()
msg['Subject'] = SUBJECT
msg['From'] = FROM_CLIENT_EMAIL
msg['To'] = TO_CLIENT_EMAIL
#THE ERROR BELOW
s = smtplib.SMTP('localhost')

I understand that there is no mail server on localhost, but how do I make a mail server on that and if I can't then why does s = smtplib.SMTP('gmail.com') take so long if it even works? What do I need to make it work? Any help is appreciated.

output: >> Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
  s = smtplib.SMTP('gmail.com')
File "C:\Python25\lib\smtplib.py", line 244, in __init__
  (code, msg) = self.connect(host, port)
File "C:\Python25\lib\smtplib.py", line 310, in connect
  raise socket.error, msg
error: (10013, 'Permission denied')

And the gmail smtp code takes too long.

Henry
  • 88
  • 1
  • 1
  • 12

0 Answers0