Mime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sangeeth
    New Member
    • Dec 2006
    • 23

    Mime

    Code:
    def sendMail(to, subject,text,files=[],server="127.0.0.1"):
            assert type(to)==list
            assert type(files)==list
            fro = "xx@x.com"
    
            debug_print("CWD -> " + os.getcwd())
            msg = MIMEMultipart()
            msg['From'] = fro
            msg['To'] = COMMASPACE.join(to)
            msg['Date'] = formatdate(localtime=True)
            msg['Subject'] = subject
    
            msg_body =  MIMEBase('text', "html")
            msg_body.set_payload(text1)
    
    
            msg.attach(msg_body)
            
            for file in files:
                    part = MIMEBase('application', "octet-stream")
                    part.set_payload( open(file,"rb").read() )
                    Encoders.encode_base64(part)
                    part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(file))
                    msg.attach(part)
    
            smtp = smtplib.SMTP(server)
            smtp.sendmail(fro, to, msg.as_string() )
            smtp.close()
    Why is that for msg_body of bigger size I see some junk characters like "! and ;" appear.
    Is there any limitation on the size of the mail sent.
    help please
Working...