[Tutor] Initiating an external email transmission

dw bw_dw at fastmail.fm
Fri Jan 23 04:09:24 CET 2015

I have a python script that I've created.
It logs into an online email service and sends out an email.
It works in my Linux box, and it works in my Windows 7 box.
I've also converted it with Py2EXE and it works as an executable in my
Win-7 box.

The issue is, I made it for someone else to use in his PC.
And its not working for him.
His system is Windows 7.
And I'm wondering if perhaps he has a firewall blocking it?
Its his personal laptop.
Any thoughts would be appreciated
here is the code with account info x'd out

#this is a funky way of clearing the screen
for x in range(0, 20):

#Use checkip.dynds.org to get IP address 
import urllib2
u = urllib2.urlopen('http://checkip.dyndns.org')
myIP = u.next()
print("The data returned is: \n%s"%myIP)

#Now we parse the returned string leaving only the IP address

#include the python SMTP library file
import smtplib
print("Importing smtplib file")

#Call SMTP library function to establish the email service
#Here we need the server name and the port assignment
print("Establishing server variables")
server = smtplib.SMTP('xxx.xxxxxxx.xxx', 587)
print("Establishing SMTP protocol ehlo")

#Next establish the user account of the online email service
#we establish a connect using the user account credentials
print("Establishing login")

server.login("xxxxx at xxxxx.com", "xxxxxxxx")

#Use the variable 'msg' for the text within the message
print("creating message")

msg = "\r\n".join([
  "From: xxx at xxxxx.com",
  "To: xxx at xxxxx.com",
  "Subject: Automated Test Message from Python program",
  "The IP address of this PC is %s" % (myIP)

#Establish FROM and TO email addresses
fromaddr="xxxx at xxxx.com"
toaddr="xxxx at xxxxx.com"

#Send the message
print("Sending email")
server.sendmail(fromaddr, toaddr, msg)
 Bw_dw at fastmail.net

More information about the Tutor mailing list