代码拉取完成,页面将自动刷新
同步操作将从 Pomdperde/MARL-DPP 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
import smtplib
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
class MailMan:
"""
Class is used to mail some information to list of mail ids.
"""
def __init__(self, user_name, password):
self.smtp_server = 'smtp.gmail.com'
self.smtp_host = 587
self.user_name = user_name
self.password = password
self.smtp = smtplib.SMTP(self.smtp_server, self.smtp_host)
def login_to_mail(self):
self.smtp.ehlo()
self.smtp.starttls()
self.smtp.ehlo()
self.smtp.login(self.user_name, self.password)
def send_text(self, subject, text_content, receiver_list):
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = self.user_name
text = MIMEText(text_content)
msg.attach(text)
for receiver in receiver_list:
msg['To'] = receiver
self.smtp.sendmail(self.user_name, receiver, msg.as_string())
pass
def send_image_with_text(self, subject, text_content, img_file_name, receiver_list):
img_data = open(img_file_name, 'rb').read()
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = self.user_name
text = MIMEText(text_content)
msg.attach(text)
image = MIMEImage(img_data, name=os.path.basename(img_file_name))
msg.attach(image)
for receiver in receiver_list:
msg['To'] = receiver
self.smtp.sendmail(self.user_name, receiver, msg.as_string())
pass
def send_text_file_with_text(self, subject, text_content, text_file_name, receiver_list):
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = self.user_name
text = MIMEText(text_content)
text_file_data = MIMEText(open(text_file_name, 'r').read().splitlines()[-1])
msg.attach(text); msg.attach(text_file_data)
# image = MIMEImage(img_data, name=os.path.basename(img_file_name))
# msg.attach(image)
for receiver in receiver_list:
msg['To'] = receiver
self.smtp.sendmail(self.user_name, receiver, msg.as_string())
pass
def quit_mail_man(self):
self.smtp.quit()
# """
# Example
# """
# # user_name = '[email protected]'
# # password = 'yash@123'
# # img_file_name = 'design_patterns.png'
# # mm = MailMan(user_name=user_name, password=password)
# # mm.login_to_mail()
# # mm.send_text(subject='Class_Test', text_content='Checking class is working or not',
# # receiver_list=['[email protected]', '[email protected]'])
# # mm.quit_mail_man()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。