Created
October 25, 2011 05:43
-
-
Save joneskoo/1311419 to your computer and use it in GitHub Desktop.
Python spammer with unicode support
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
#!/usr/bin/env python3 | |
# encoding: utf-8 | |
import smtplib | |
from email.message import Message | |
from email.header import Header | |
from email.utils import formataddr | |
SMTP_SERVER = 'mail.suomi.net' | |
FROM_NAME = 'Example Sender' | |
FROM_EMAIL = 'from@example.com' | |
TOADDRS = [('Example Receiver', 'to@example.com')] | |
TEXT = "Tässäpä on pitkä tekstiviesti.\nÄäkköset ja €-merkit eivät ole ongelma." | |
SUBJECT = "Tämä on taas kerran testiviesti" | |
def main(): | |
from_header = "{} <{}>".format(Header(FROM_NAME), FROM_EMAIL) | |
subject = Header(SUBJECT, 'utf-8') | |
server = smtplib.SMTP(SMTP_SERVER) | |
server.set_debuglevel(1) | |
for to_name, to_email in TOADDRS: | |
msg = Message() | |
msg['Subject'] = subject | |
msg['From'] = from_header | |
msg['To'] = "{} <{}>".format(Header(to_name), to_email) | |
msg.set_payload(TEXT, 'utf-8') | |
server.sendmail(FROM_EMAIL, to_email, msg.as_string()) | |
server.quit() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not validate to_email, which may be bad if the email source is untrusted