problem with sending email

Haris Lekatsas nospam at newsranger.com
Mon Jul 2 07:56:14 CEST 2001


I have a problem running the script below on FreeBSD. When I run it from the
UNIX prompt it runs fine and it sends a file (bigtextfile) of any size to
the recipient address. Whenever a run the exact same script from a web 
browser as a CGI script it will send only about 17K of the bigfile and not
the whole thing. I tried many different files and all of them get cut off
at around 17K. It seems on other OS this problem does not appear. Any ideas
why this is happening would be appreciated.

Thanks!
Haris Lekatsas 

#!/usr/bin/env python
import socket, smtplib

server = smtplib.SMTP()
server.connect('localhost')
server.helo('localhost')

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('bigtextfile', 'r')
text = ''
while 1:
line = fd.readline()
if not line: break
text = text + line
fd.close()

msg = msg + '\012' + text

tmp_output = server.sendmail("lekatsas at jayway.com", "lekatsas at ee.princeton.edu",
m
sg)

print "Content-type: text/html\n\n"
print "Mail sent!"





More information about the Python-list mailing list