#!/usr/bin/env python """Sends an email. """ __revision__ = '0.0.5' import sys # Import smtplib for the actual sending function import smtplib # Import the email modules we'll need from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart from email import Encoders #sender = 'cciupitu@nuxeo.com' #recipient = 'avoinea@nuxeo.com' #recipient = sender = 'christi@mir.lizeanunet.ro' sender = 'proXoare@kix.ro' recipient = 'avoX@Xxeo.com' filename = sys.argv[1] outer = MIMEMultipart() outer['Subject'] = 'The contents of %s' % filename outer['From'] = sender outer['To'] = recipient outer.preamble = 'Attached is the contents of:\n%s' % filename outer.epilogue = '' # Create a message maintype, subtype = 'application', 'octet-stream' msg = MIMEBase(maintype, subtype) msg.set_payload(open(filename, 'rb').read()) # Encode the payload using Base64 Encoders.encode_base64(msg) msg.add_header('Content-Disposition', 'attachment', filename=filename) # Attach the file outer.attach(msg) # Send the message via our own SMTP server, but don't include the # envelope header. #s = smtplib.SMTP('localhost') s = smtplib.SMTP() print 's.connect()' s.connect() print 's.sendmail(...)' s.sendmail(sender, [recipient], outer.as_string()) print 's.close(...)' s.close()