Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from email.mime.text import MIMEText
- from smtplib import SMTP_SSL, SMTPException
- import logging
- def admin_email(recipients, subject, content):
- smtp_server = ''
- sender = ''
- username = sender
- password = ''
- text_subtype = 'html'
- try:
- msg = MIMEText(content, text_subtype)
- msg['Subject'] = subject
- msg['From'] = sender
- for i in recipients:
- if not i:
- recipients.remove(i)
- if recipients != [None]:
- msg['To'] = ', '.join(recipients)
- else:
- recipients = []
- conn = SMTP_SSL(smtp_server)
- conn.set_debuglevel(False)
- conn.login(username, password)
- try:
- conn.sendmail(sender, recipients + [''], msg.as_string())
- finally:
- conn.close()
- except SMTPException:
- e = sys.exc_info()[0]
- # Log (e)
- logging.error(e)
Add Comment
Please, Sign In to add comment