[Tutor] slightly less maaningless drivel ensues

Kirk Bailey deliberatus@my995internet.com
Wed, 12 Dec 2001 01:13:19 -0500


HEY! This works ok! No horrors! I received the message it sent!


------------------------begin fresh bits--------------------------------
#!/usr/local/bin/python
                                # so the script is executable
import smtplib                  # import the smtp routines
import string                   # and string manipulation stuff

CRLF=("\r"+"\n")                        # we will be tagging CRLF onto
several things.
                                        # so this is handy.

def prompt(prompt):
        return string.strip(raw_input(prompt))  # prompt, get, strip,
return.


fromaddr = prompt("From: ")             # get the from address.
toaddrs  = prompt("To: ")               # get the to address.
subject = prompt("Subject: ")           # get the subject.

print "Enter message, end with ^D:"     # Add the From: and To: headers
at the start!

msg = "From: " + fromaddr + CRLF + "To: " + toaddrs + CRLF + "Subject: "
+ subject + CRLF +
 CRLF

while 1:
        try:
                line = raw_input()
        except EOFError:
                break
        if not line:
                break
        msg = msg + line + CRLF

print type(msg)

print "Message length is " , len(msg) , " bytes long."

server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()


ns# 
------------------------end limberger--------------------------

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end


Within the sweep of his sword, Each man is an Ubar.

http://www.howlermonkey.net/
http://www.sacredelectron.org/