smtplib send email with set email image

28 views Asked by At

**i try to send email with set email image **

Next to the message title there is a small picture. I am trying to change it to reflect the nature of the email sent in each sending process

enter image description here

def check(line):
   arre = str(line).split(':')
   print(arre)
   mail_username="username"
   mail_password="password"
   try:
      from_addr = mail_username
      to_addrs=('[email protected]')
      HOST = "smtpDomain"
      print(HOST)
      PORT = 587
      smtp = smtplib.SMTP(HOST)
      smtp.connect(HOST,PORT)
      time.sleep(2)
      smtp.ehlo()
      smtp.starttls()
      try:
         smtp.login(mail_username,mail_password)
         print ("goodlogin")
         smtp.set_debuglevel(1)
         msg = MIMEMultipart()
         msg['From'] = "[email protected]"
         msg['To'] = to_addrs
         msg['Reply-to'] = "[email protected]"
         msg['Subject']='test message'
         msg.add_header('Content-Type', 'text/html')
         data = line
         msg.attach(MIMEText(data, 'html', 'utf-8'))
         print(smtp)
         smtp.sendmail(from_addr,[msg['To']],msg.as_string())
         print ("done")
      except Exception as ee:
         print( ee)
      smtp.quit()
   except Exception as ee:
                          print ("asd")
                          print (ee)

I need help on how to send a different image

0

There are 0 answers