[Tutor] slightly updated version of same script
Kirk Bailey
deliberatus@my995internet.com
Wed, 12 Dec 2001 01:21:38 -0500
Here ya go. Took out the extra crof and the testing code with the type
statement.
Now that I can get this working, I need to go play with DIGESTING
incoming email and examining header information. Good thing I trapped a
few incoming letters into files in the server so I have data to feed the
script for testing.
Any and all, feel free to examine this and comment on anything you like.
-------------------burst along this line, scattering intestines
everyplace else---------------
#!/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 to have
around.
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
while 1:
try:
line = raw_input()
except EOFError:
break
if not line:
break
msg = msg + line + CRLF
print "Message length is " , len(msg) , " bytes long."
server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
------------------------end---------------------------
--
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/