[Tutor] further ignorant babbling, but with prettier words

Kirk Bailey highprimate@howlermonkey.net
Sun, 9 Dec 2001 17:26:7 -0500

Lookee what I been up to.

----------begin seasoned bits----------------
# Tinylist module, Pitchtime unit.
# this handles receiving and sending out postings to a list.

import sys, re, string, rfc822, smtplib

localhost = 'howlermonkey.net'	# make sure you set this to the domain YOU use!!!

pathtostuff = '/www/www.howlermonkey.net/cgi-bin/'	#please edit this to suit your system.
						# note this tells where to start looking.
						# everything is either here, ur under this
						# point in a systematic manner.
listname = argv[1]			# we read a command line arguement to determine the list 
						# Arguement 0 is the name of the script run, 1 is the
						# first arguement
						# after that name in the command line, so if this were
						# program FOO,
						# that line would be "|/path/FOO listname"
						# and the arguement here would be 'listname'!
message = raw_input.lines()		# Variable 'message' is assigned the entire message
						# which is piped to the program by the alias definition
						# such as:
						# foolist:"|/pathtoprogram/programname foolist"

						# now we must determine the sender and see if they are in
						# the subscriber file!
from = message["From"]

open a.file(pathtostuff + "/lists/" + listname, 'r')						
members = a.readlines()

if pos( from, message] :	# IF the sender is in the subscriber file, THEN:
		subject = '[' + listname + ']' + subject		# '[listname] whatever they said'
		X-Mailing-List = listname + "@" + localhost	# This breaks email loops from 
		Reply_to = listname + "@" + localhost		# this sets the reply-to field.
		listnamemembers = from	# only one 'member' in the list of 'subscribers' here!
		message = ""		# clear the unauthorized posting.
		From = "From: tinylist@" + localhost + \n # From: tinylist@mydomain.foo !
		Subject = message + "Subject: Unauthorized posting to list" + listname + \n
		Reply_to = message + "Reply-to:postmaster@" + localhost + \n
		message = message + """
		To whom it may concern;
		Sorry, but as you are not a current member of """ + listname + """, 
		you may not post to it. Your recent posting has been rejected and destroyed.
		Feel free to contact the postmaster if there is any question.
		Any reply to this letter should go directly to the postmaster.
		You can also subscribe to this list if you like.

# ok, if they are not a member, THEY GET THE REPLY SHOWN ABOVE MAILED TO THEM!
# above is a blank line, DO NOT DELETE IT! it defines the end of the if then else 
# there is no endif or fi in python. whitespace is rather important here.
# now we send whatever message is to go out to whatever is in the recipient tupple.

for i in listnamemembers :
	a.sendmail(from_addr, to_addr, Subject, reply-to, to, X-Mailing-List, msg)
# make sure this script runs as a TRUSTED USER- and NOT as root!!! Make sure a
# NON-priviliged user can run this script, and make sure it is owned by that identity!
--------------end seasoned bits------------


In total confusion,
                   Kirk D Bailey

|           Consulting  Agent  Provecateur           |
|    Webmaster, Howlermonkey Email services Co.      |
|   Please visit us at http://www.howlermonkey.net/  |