smtp
Cliff Wells
logiplexsoftware at earthlink.net
Wed Oct 24 19:01:06 EDT 2001
I'm trying to add a "Contact Us" button to a Python app. Using the smtplib
module was straightforward and works from Linux using 'localhost' as the
server (sendmail handles it), but this doesn't work on a Windows box. I
worked around this by using our ISP's mail server which works fine if I am
sending the email (even if I send it using a different email address for the
sender) from my PC or from a coworkers. However - I tried it on someone
else's Windows PC who uses AOL (blech) and it failed with SMTPSenderRefused.
The problem is easily reproduced using the code from the smtplib module but
substituting "mail.earthlink.net" (my ISP) in place of "localhost" and my
email address for the toaddrs:
import smtplib
import string
def prompt(prompt):
return raw_input(prompt).strip()
fromaddr = prompt("From: ")
# toaddrs = prompt("To: ").split()
toaddrs = ["logiplexsoftware at earthlink.net"]
print "Enter message, end with ^D:"
# Add the From: and To: headers at the start!
msg = ("From: %s\r\nTo: %s\r\n\r\n"
% (fromaddr, string.join(toaddrs, ", ")))
while 1:
try:
line = raw_input()
except EOFError:
break
if not line:
break
msg = msg + line
print "Message length is " + `len(msg)`
server = smtplib.SMTP('mail.earthlink.net')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
It seems it should be legal to send directly to that server, since that's the
final destination anyway. Am I wrong, or is just AOL? I don't have access
to enough separate ISP's to test this very well.
Thanks in advance,
--
Cliff Wells
Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308
More information about the Python-list
mailing list