Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def enviaremail(usuario,senha,mensagem,listadestinatarios):
- from smtplib import SMTP
- smtp=SMTP('smtp.live.com',587)
- smtp.starttls()
- smtp.login(usuario,senha)
- smtp.sendmail(usuario,listadestinatarios,mensagem)
- smtp.quit()
- print('E-mail enviado com sucesso')
- def anexoimagem(path):
- from email.mime.image import MIMEImage
- with open(path,'rb') as f:
- mime=MIMEImage(f.read(),subtype='jpg')
- return mime
- msg=anexoimagem('foto.jpg')
- msg['From']='xxxx@hotmail.com'
- msg['To']='xxxx@hotmail.com'
- msg['Subject']='testando mensagem com anexo'
- enviaremail('xxxx@hotmail.com','xxxx',msg.as_string,['xxxx@hotmail.com']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement