此代码适用于我的本地服务器,但不适用于主机。可能是什么问题?
import _thread
def email_index(*args):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('ki@gmail.com', 'pas')
try:
server.sendmail('ki@gmail.com', 'so@gmail.com', body_mes.encode('utf-8'))
print('ok')
except:
print('An error occurred when trying to send an email')
try:
_thread.start_new_thread( email_index, ("Thread-1", 2, ) )
except:
print ("Error: unable to start thread")