On Wed, 20 May 2009 17:49:47 +0530 Kalyan Chakravarthy <kalyanchakravar...@hyit.com> wrote:
> Hi > Now i can able to get the form details in to python code, > > can any one tell me the format to send form values to one Emil > id ... for this I required SMTP set up? You can use email and smtplib modules for that along with any SMTP relay you have access to, even if it requires authentication - smtplib has support for that. Following example doesn't uses authentication for SMTP so you might want to add it or you can indeed set up some SMTP on local machine (there are really simple ones like ssmtp or msmtp, that can relay mail to auth-enabled host). import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText from email.Utils import COMMASPACE, formatdate from email import Encoders import os, collections def send(to, subj, body, files=[], from=None, relay='localhost'): if not isinstance(to, collections.Iterable): to = (to,) msg = MIMEMultipart() msg['From'] = from msg['To'] = COMMASPACE.join(to) msg['Date'] = formatdate(localtime=True) msg['Subject'] = subj msg.attach( MIMEText(body) ) for file in files: part = MIMEBase('application', "octet-stream") part.set_payload( open(file,"rb").read() ) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"'% os.path.basename(file)) msg.attach(part) smtp = smtplib.SMTP(relay) smtp.sendmail(from, to, msg.as_string() ) smtp.close() -- Mike Kazantsev // fraggod.net
signature.asc
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list