Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
verify-email/send_mail.py /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (33 sloc)
1.12 KB
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 python | |
| import time | |
| import smtplib | |
| from email.mime.multipart import MIMEMultipart | |
| from email.mime.text import MIMEText | |
| msgtxt = """ | |
| <html> | |
| <head></head> | |
| <body> | |
| <p>*this is a test*<br>Hi {name}, please verify your Sugar Labs mail address by clicking the link below<br><b><a href="{url}">Confirm email</a></b></p> | |
| <small>If you are not able to click the link, please copy this address into your web browser:<br> | |
| <b>{url}</b> | |
| </small> | |
| </body> | |
| </html>""" | |
| server = "http://people.sugarlabs.org:5001/?verify=" | |
| f = open("mails.txt", "r") | |
| mails = f.readlines() | |
| f.close() | |
| for mail in mails: | |
| name, email, vhash = mail.split("|") | |
| msg = MIMEMultipart('alternative') | |
| msg['Subject'] = "[Sugar Labs] Please verify your mail address" | |
| msg['To'] = email | |
| msg['From'] = "members@sugarlabs.org" | |
| url = "%s%s" % (server, vhash) | |
| msghtml = MIMEText(msgtxt.format(url=url, name=name), 'html') | |
| msg.attach(msghtml) | |
| s = smtplib.SMTP('localhost') | |
| s.sendmail("members@sugarlabs.org", email, msg.as_string()) | |
| s.quit() | |
| # Wait 5 seconds before sending the other | |
| time.sleep(5) |