Created
September 16, 2016 23:40
-
-
Save dawranliou/6b79cb6519840b8b2ec0f6f77e632292 to your computer and use it in GitHub Desktop.
Office pranks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
import email.utils | |
from email.mime.text import MIMEText | |
from collections import namedtuple | |
Prankee = namedtuple('Prankee', 'name id email') | |
colleague = Prankee('Colleague', 'colleague_id', 'colleague@email.com') | |
subject = '[IT Information] %s we detect unauthorized actions from your account' % colleague.name | |
body = '''Dear user %s (%s), | |
IT detected unauthorized actions from your account. | |
If this wasn't you. It's very likely your account has been hacked. | |
Please change you credential immediately. | |
Have a great day, | |
-your friend in IT | |
''' % (colleague.id, colleague.name) | |
sender = ('IT-Information', 'IT.Information@email.com') | |
recipients = [(colleague.name, colleague.email)] | |
msg = MIMEText(body) | |
msg['To'] = ', '.join([email.utils.formataddr(recpt) for recpt in recipients]) | |
msg['From'] = email.utils.formataddr(sender) | |
msg['Subject'] = subject | |
with smtplib.SMTP('mail') as server: | |
# server.set_debuglevel(True) | |
server.sendmail(sender, recipients, msg.as_string()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment