#!/usr/bin/python # # Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com) # # Jeroen van Meeuwen (Kolab Systems) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 3 or, at your option, any later version # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # import smtplib import socket import sys # For development purposes sys.path.extend(['.', '..']) 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_from, send_to, send_with=None): smtp = smtplib.SMTP("localhost", 8025) smtp.set_debuglevel(True) subject = "This is a Kolab load test mail" text = """Hi there, I am a Kolab Groupware test email, generated by a script that makes me send lots of email to lots of people using one account and a bunch of delegation blah. Your response, though completely unnecessary, would be appreciated, because being a fictitious character doesn't do my address book of friends any good. Kind regards, Lucy Meier. """ msg = MIMEMultipart() msg['From'] = send_from msg['To'] = COMMASPACE.join(send_to) msg['Date'] = formatdate(localtime=True) msg['Subject'] = subject msg.attach( MIMEText(text) ) #msg.attach( MIMEBase('application', open('/boot/initrd-plymouth.img').read()) ) smtp.sendmail(send_from, send_to, msg.as_string()) if __name__ == "__main__": #send_to = [ #'Jeroen van Meeuwen ', #'Aleksander Machniak ', #'Georg Greve ', #'Paul Adams ', #'Thomas Broderli ', #'Christoph Wickert ', #'Lucy Meier ', #] #send_mail( #'Jeroen van Meeuwen ', #send_to #) #send_mail( #'Lucy Meier on behalf of Paul Adams ', #send_to #) #send_mail( #'Lucy Meier on behalf of Georg Greve ', #send_to #) send_to = [ 'Jeroen van Meeuwen ' ] send_mail('Jeroen van Meeuwen ', send_to)