sendMail problem

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

    sendMail problem

    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
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Where are these "junk characters" appearing? In the received email? In the message body? The subject line? The attachments?
    Please elaborate.

    Also, take a look at your data before you call the send function, does the information all look correct?

    Comment

    • sangeeth
      New Member
      • Dec 2006
      • 23

      #3
      Originally posted by Motoma
      Where are these "junk characters" appearing? In the received email? In the message body? The subject line? The attachments?
      Please elaborate.

      Also, take a look at your data before you call the send function, does the information all look correct?
      The junk character "!" is appearing in the message body
      The junk character appears exactly after 2615 characters.
      The text is fine before sending it through sendmail.

      Comment

      Working...