def send_mail(server, from_address, from_name, to_address, subject, body_arg, return_addr, tls):
msg = MIMEMultipart('alternative')
msg['To'] = to_address
msg['Date'] = formatdate(localtime = True)
msg['Subject'] = subject
msg.add_header('reply-to', return_addr)
msg.add_header('from', from_name + "<" + from_address + ">")
part1 = MIMEText(body_arg, 'plain')
part2 = MIMEText(body_arg, 'html')
msg.attach(part1)
msg.attach(part2)
try:
smtp = smtplib.SMTP(server)
smtp.set_debuglevel(VERBOSE)
smtp.sendmail(from_address, to_address, msg.as_string())
smtp.quit()
except smtplib.SMTPException:
print FAIL + "[-] Error: unable to send email to ", to_address, ENDC
# --------------------- PARSE includes/config.massmail -------------------
评论列表
文章目录