problem with sending email
lekatsas at ee.princeton.edu
Wed Jul 4 04:55:56 CEST 2001
In article <qZj07.26346$he.1368759 at e420r-atl1.usenetserver.com>, Steve Holden
>"Haris Lekatsas" <lekatsas at EE.Princeton.EDU> wrote in ...
>> This works thanks!
>> Unfortunately it makes my scripts less portable as the path to
>> sendmail has to be specified (not always at /usr/sbin/sendmail)
>> but this seems to be the only solution I have so far.
>> I wonder if python's smtplib is broken.
>Certainly not *that* broken. On Windows platforms it sends megabytes of mail
>for me every month, some of it single messages with 2MB zipfile attachments.
>Don't currently use it on Unix.
>I notice in your original code you assemble the message line-by-line,
>reading from a text file. You could think about
>a) Putting debug outputs in there to see what message length is being passed
>to SMPT.sendmail(), or
>b) Using read() to suck the whole thing in - if line endings are a problem
>you could use replace() to ensure they are correct.
>But you really should check what sendmail() is being given, so you know
>where to look next for the possible error.
It seems sendmail is really getting the whole input. I am now printing msg and
i get the whole thing. Also the debugging level is set to 1. As before, running
it from the shell it will run fine, running it from the web as a cgi
script will only send 17,988 bytes of the text. However it will print that the
message was sent fine and the whole msg string will appear on screen from the
last print statement.
It might have something to do with the HTTP server...
import socket, smtplib
server = smtplib.SMTP()
msg = "From: " + "Haris Lekatsas <lekatsas at jayway.com>" + "\012"
msg = msg + "To: " + "Haris Lekatsas <lekatsas at ee.princeton.edu>" + "\012"
msg = msg + "Subject: " + "subject" + "\012"
fd = open('thelib.py', 'r')
text = ''
text = fd.read()
msg = msg + '\012' + text
tmp_output = server.sendmail("lekatsas at jayway.com", "lekatsas at ee.princeton.edu",
print "Content-type: text/html\n\n"
More information about the Python-list