Sunday 31 January 2016

python - SMTP works in Linux but not on Mac

When I run the following code in Linux, it sends, the email, however, in Mac, it fails to run at line server = smtplib.SMTP("smtp.gmail.com", "587")



import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

import subprocess as s
import sys
import os

def send_email(predicted_change, sentiment, coin, toaddr):
fromaddr = "****@gmail.com"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "Predicted Price Change Of " + coin


body = "The sentiment of the last 60 minutes for " + coin + " is : " +
sentiment + " - The predicted change in price is : " + predicted_change
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP("smtp.gmail.com", "587")
server.starttls()
server.ehlo()
server.login(fromaddr, "****")
text = msg.as_string()
print(text)

server.sendmail(fromaddr, toaddr, text)
server.quit()
print("Over")


I get this error



 socket.error: [Errno 60] Operation timed out

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...