I am using Python smtp module sending mail, it's send success and looks good in outlook. By when I checking in mobile phone, it's no content but only attachment.Actually there are three tables in content. Is anyone know how to fix this issue? Below is my code.
def send_mail(subject, sender, recipient, cc, toaddrs, body, filename):
msg = MIMEMultipart('alternative')
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = ", ".join(recipient)
msg['Cc'] = ", ".join(cc)
message = MIMEText(body, 'html') # html.read(), 'html')
msg.attach(message)
attachment = MIMEBase('application', 'octet-stream')
attachment.set_payload(open(filename, 'rb').read())
encoders.encode_base64(attachment)
attachment.add_header(
'Content-Disposition', 'attachment; filename="%s"' % os.path.basename(filename))
msg.attach(attachment)
smtp = smtplib.SMTP('localhost')
smtp.sendmail(sender, toaddrs, msg.as_string())
logger.info('Email have sent successfully!')
smtp.quit()
Any help will be appreciate. Thanks.