reg email packages work

Tim Roberts timr at probo.com
Fri Sep 2 03:14:01 EDT 2005


praba kar <prabapython at yahoo.co.in> wrote:
>
>       I am working in web based email system project.
>Here I try to build email message
>from scratch. I used below code to build email
>message
>
>   msg =  email.MIMEBase('text','html')
>   msg['Return-Path'] = user+'@'+domain
>   msg['Date'] = formatdate(localtime=1)
>   msg['Subject'] =  subject
>   msg['From'] = from_name
>   msg['To'] = to
>   msg['Cc'] = cc
>   msg.set_payload("Body of the email messagge")
>   fh = os.popen('/bin/sendmail  %s'% (eachid),'w')
>   fh.write(msg.as_string())
>   fh.close()
>
>This code will build plain email message properly.

No, it doesn't.  It builds an HTML message (see the very first line).  If
you supply plain text to this as the body of the message, all the lines
will be concatenated together, which sounds a lot like what you are seeing.

If you are not feeding HTML as the body, change the fist line to
('text','plain').
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list