- Já testei o telnet e a conexão foi bem sucedida. Alguém poderia me ajudar?
- Já tentei tb aumentar o timout.
Nada disso deu certo. Alguém poderia me ajudar?
Segue abaixo o código:
def enviar_email():
corpo_email = """
<p>Teste de envio de msg com Python</p>
<p>Parágrafo2</p>
"""
# msg = email.message.Message()
# msg['Subject'] = "Assunto"
# msg['From'] = 'remetente'
# msg['To'] = 'destinatario'
# password = 'senha'
msg = email.message.Message()
msg['Subject'] = "Teste"
msg['From'] = '
xx...@gmail.com'
msg['To'] = '
y...@gmail.com'
password = 'senha'
msg.add_header('Content-Type', 'text/html')
msg.set_payload(corpo_email )
# socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, '10.1.60.11', 80)
# socks.wrapmodule(smtplib)
#s = smtplib.SMTP('
smtp.gmail.com')
s = smtplib.SMTP('
smtp.gmail.com', 587, timeout=240)
#s = smtplib.SMTP_SSL('
smtp.gmail.com', 465)
s.starttls()
# Login Credentials for sending the mail
s.login(msg['From'], password)
s.sendmail(msg['From'], [msg['To']], msg.as_string().encode('utf-8'))
print('Email enviado')
enviar_email()