Communications with Gmail got stuck today for exactly one my account. For another one it's OK. The code is exactly the same. How come? Any help or ideas?
Log from the affected account:
2018-03-29 19:46:13,678: send: 'ehlo [127.0.0.1]\r\n'
2018-03-29 19:46:13,704: reply: '250-smtp.gmail.com at your service, [23.23.219.95]\r\n'
2018-03-29 19:46:13,711: reply: '250-SIZE 35882577\r\n'
2018-03-29 19:46:13,718: reply: '250-8BITMIME\r\n'
2018-03-29 20:33:50,072: reply: '250-STARTTLS\r\n'
and it is still stuck there.
Account name is newadventures
.
Python code:
import smtplib
from email.mime.text import MIMEText
import logging
log = logging.getLogger(__name__)
import threading
class EmailThread(threading.Thread):
def __init__(self,
server_name=settings.EMAIL_HOST,
port=settings.EMAIL_PORT,
sender=settings.EMAIL_HOST_USER,
pwd=settings.EMAIL_HOST_PASSWORD,
to=[],
subj='',
msg=''
):
super(EmailThread, self).__init__()
self.server_name = server_name
self.port = port
self.sender = sender
self.pwd = pwd
self.to = to
self.subj = subj
self.msg = msg
def run(self):
if self.to:
server = smtplib.SMTP(self.server_name, self.port)
server.set_debuglevel(1)
msg = MIMEText(self.msg.encode('utf-8'), 'html', 'UTF-8')
msg['Subject'] = self.subj
msg['From'] = self.sender
msg['To'] = ", ".join(self.to)
server.starttls()
server.login(self.sender, self.pwd)
server.sendmail(self.sender, self.to, msg.as_string())
server.quit()