Posted by comprookie2000 on Sun 7 Jun 00:09
report abuse | download | new post
- #!/usr/bin/python
- from time import sleep
- import smtplib
- import os
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEBase import MIMEBase
- from email.MIMEText import MIMEText
- from email.Utils import COMMASPACE, formatdate
- from email import Encoders
- def send_mail(send_to, subject, text, files=[],
- server="mail.yourserver.net"):
- assert type(send_to)==list
- assert type(files)==list
- send_from = "Grateful User <user@grateful.net>"
- msg = MIMEMultipart()
- msg['From'] = send_from
- msg['To'] = COMMASPACE.join(send_to)
- msg['Date'] = formatdate(localtime=True)
- msg['Subject'] = subject
- msg.attach( MIMEText(text) )
- for f in files:
- part = MIMEBase('application', "octet-stream")
- part.set_payload( open(f,"rb").read() )
- Encoders.encode_base64(part)
- part.add_header(
- 'Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
- msg.attach(part)
- smtp = smtplib.SMTP(server)
- smtp.sendmail(send_from, send_to, msg.as_string())
- smtp.close()
- def message(address):
- body = "Just a short note to say thank you for all the time and work you put into Gentoo.\n user aka (gentoo_guru)\n\n http://linux.com"
- send_mail(
- [address],
- "Thanks", body)
- def send_message():
- all_addresses = ['dev1@gentoo.com', 'dev2@gentoo.com']
- for address in all_addresses:
- message(address)
- send_message()
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.