Forums

socket problem email yahoo

My scrape scrypt sends the results of the scraping in a email. This scrypt is working on my computer. But the same scrypt is not working in pythonanywhere. How do i solve this? Is this a yahoo thing?

import smtp

This is the error:

Traceback (most recent call last): File "/home/myproject/puppies-pythany.py", line 74, in <module> server = smtplib.SMTP('smtp.mail.yahoo.com', 587) File "/usr/lib/python2.7/smtplib.py", line 256, in init (code, msg) = self.connect(host, port) File "/usr/lib/python2.7/smtplib.py", line 316, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket return socket.create_connection((host, port), timeout) File "/usr/lib/python2.7/socket.py", line 571, in create_connection raise errsocket.error: [Errno 111] Connection refused

email_user = 'xx@yahoo.com'
email_password = 'xxxxx'
email_send = 'xx@yhaoo.com'
subject = key 
msg = MIMEMultipart()
msg['From'] = email_user
msg['To'] = email_send
msg['Subject'] = subject
body = ' ' + key + '!'
msg.attach(MIMEText(body,'plain'))
attachment = open(filename,'rb')
part = MIMEBase('application','octet-stream')
part.set_payload((attachment).read())
encoders.encode_base64(part)
part.add_header('Content-Disposition',"attachment; filename= "+filename) 
msg.attach(part)
text = msg.as_string()
server = smtplib.SMTP('smtp.mail.yahoo.com', 587)
server.ehlo()
server.starttls()
server.login(email_user,email_password)
server.sendmail(email_user,email_send,text)
server.quit()
driver.close()

As a free user you can only use google for smtp. See this.

thanks