Using Python smtplib

From PeformIQ Upgrade
Jump to navigation Jump to search
#!/usr/bin/env python
#
#  $Id: smtp_send.py,v 1.1 2003/11/13 00:39:44 plh Exp $
#
#---------------------------------------------------------------------

import smtplib

#---------------------------------------------------------------------

debugLvl    = 2

host        = "mail.xxx.net"
fromaddr    = "pharding@xxx.com"
toaddr      = "xxx-au@xxx.net"
awbNo       = "1709363250"
awbNo       = "2010045100"
activityNo  = "166"

MSG = """\
From: "Peter Harding" <%s>
To: <%s>
Subject: REPLY: %s
Date: Thu, 30 Oct 2003 14:35:10 +1100
Message-ID: <000701c39e96$d2c8e4d0$2d81a8c0@agentis.net>
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
	Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0)
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
In-Reply-To: <2305487.1067484548519.JavaMail.weblogic@reaper1>

TR NO. : %s
"""

#---------------------------------------------------------------------

msg = MSG % (fromaddr, toaddr, awbNo, activityNo)

print "Message length is %d" % len(msg)

server = smtplib.SMTP(host)
server.set_debuglevel(debugLvl)
server.sendmail(fromaddr, toaddr, msg)
server.quit()

#---------------------------------------------------------------------