Testing Mail Delivery
Revision as of 10:12, 11 February 2008 by PeterHarding (talk | contribs)
Writing Directly to SMTP Server
# telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 localhost.localdomain ESMTP Postfix (Debian/GNU) EHLO mail.xxx.com.au 250-localhost.localdomain 250-PIPELINING 250-SIZE 67108864 250-VRFY 250-ETRN 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN MAIL From:<yyy@yyy.com.au> 250 2.1.0 Ok RCPT To:<xxx@xxx.com.au> 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> Subject: xxxxx blah blah blah . 250 2.0.0 Ok: queued as 8AFD1E4488 QUIT 221 2.0.0 Bye Connection closed by foreign host. #
Using Python Scipts
#!/usr/bin/env python # # $Id:$ # #--------------------------------------------------------------------- import smtplib #--------------------------------------------------------------------- debugLvl = 2 host = "mail.xyzzy.net" fromaddr = "xxx@xxx.com.au" toaddr = "yyy@xyzzy.net" MSG = """\ From: %s To: %s Subject: Subject This is a new message """ #--------------------------------------------------------------------- msg = MSG % (fromaddr, toaddr) print "Message length is %d" % len(msg) server = smtplib.SMTP(host) server.set_debuglevel(debugLvl) server.sendmail(fromaddr, toaddr, msg) server.quit() #---------------------------------------------------------------------