Help: sendmail under MS NT

TMGB bennettt at am.appstate.edu
Fri Aug 13 16:37:52 EDT 1999


Being new to Python, someone else may be able to give you a more
efficient way to do this or maybe a real sendmail command.  But, using
smtplib.py I found that I had to initialize mailserver with a valid mail
server and mail recipient for it to work.  I also imported cgi, urllib,
os, and my_mailtomessages which shouldn't be needed for this snippet. 
This is running Python and Netscape Enterprise Server on an intel NT box
with the form data coming from an ALPHA NT box.


------------------
import smtplib
import string

# Get form data up here or any other code you may need

# HERE BEGINS THE MAILTO Defaults PORTION OF THE SCRIPT

   mailserver="my.mailserver.appstate.edu"
   mailrecip="me at my.mailserver.appstate.edu"
   subject="ERROR"

# Asign MAILTO results from form to mailto values   
#   first get user's domain from email address and use their server to
mail from

  
mailserver=form["sentfrom"].value[string.find(form["sentfrom"].value,"@")+1:]
   mailrecip=form["sendto"].value
   subject=form["subject"].value
   sender=form["sentfrom"].value
   message=form["message"].value
   
# send the mail
   mail=smtplib.SMTP(mailserver)
   mail.sendmail(sender,mailrecip,message)
   mail.quit

--------------------

This has not been tested with a server outside of my Domain but has
worked with different accounts on different mail servers in this domain.

Thomas

Shicheng wrote:
> 
> Under unix platforms, using, for example,
> 
> sendmail_cmd = "/usr/lib/sendmail -oi "
> 
> to access the SMTP sendmail utility.
> 
> Our enquery is: under Windows NT/95/98 platforms,
> how to access the "sendmail" utility from within
> python code?
> 
> Thanks,
> 
> Shicheng
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

-- 
----------------------------------------------------------------------
Thomas McMillan Grant Bennett           Appalachian State University
Computer Consultant II                  University Library
bennettt at am.appstate.edu               
http://www.library.appstate.edu/admin/
Voice:  828 262 6587			FAX:    828 262 3001

Windows 95 is a 32-bit extension to a 16-bit patch for an 8-bit
operating system that was originally coded for a 4-bit microprocessor.
 - Chris Dunphy     Boot Magazine




More information about the Python-list mailing list