problem with sending email

Haris Lekatsas nospam at
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.

Haris Lekatsas 

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

server = smtplib.SMTP()

msg = "From: " + "Haris Lekatsas <lekatsas at>" + "\012"
msg = msg + "To: " + "Haris Lekatsas <lekatsas at>" + "\012"
msg = msg + "Subject: " + "subject" + "\012"
fd = open('bigtextfile', 'r')
text = ''
while 1:
line = fd.readline()
if not line: break
text = text + line

msg = msg + '\012' + text

tmp_output = server.sendmail("lekatsas at", "lekatsas at",

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

More information about the Python-list mailing list