I am working on a 'contact form' that like all others will mail its contents using user supplied data from a web page (I know of gypsy mail but I want to do this as a learning process for myself). I also want to try my hand at OOP for this one (have never done any OOP).
I am OK with getting the contents from the form, but it is how I handle them once I have them that has me a bit stuck. I have written what I think to be a 'module' (see code below) that I want to call from my form handling script to take care of the sending of the mail. I was hoping that:
1) Someone could tell me wether or not I am on the right track with the OOP (ie is the module the way to go or should it be a class).
2) Is the code correct - or have I missed the mark? Cold it be written better or different?
3) Am I just way off on the whole idea, and if so, could someone please give an example to get me going in the right direction?
----- here is the code -----
# this module takes care of sending the mail generated by mailform.py
HOST = "localhost"
FROM = sender
TO = recipient
SUBJECT = sbj
BODY = content
body = srting.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
server = smtplib.smtp(HOST)
server.postfix(FROM, [TO], body)
Thanks for your help,