def send_email(self):
self.make_messages()
if len(self.email_messages) > 0:
for detail in self.email_messages:
user_email = detail['email']
user_message = detail['message']
try:
email_conn = smtplib.SMTP(host, port)
email_conn.ehlo()
email_conn.starttls()
email_conn.login(username, password)
the_msg = MIMEMultipart("alternative")
the_msg['Subject'] = "Billing Update!"
the_msg["From"] = from_email
the_msg["To"] = user_email
part_1 = MIMEText(user_message, 'plain')
the_msg.attach(part_1)
email_conn.sendmail(from_email, [user_email], the_msg.as_string())
email_conn.quit()
except smtplib.SMTPException:
print("error sending message")
return True
return False
message_users.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录