Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-06-2005, 10:59 AM   #1
Registered: Oct 2003
Distribution: College Linux 2.3
Posts: 43

Rep: Reputation: 15
Apache, Python and sendmail


i have a python script running on an apache server. what i want is to be able to call sendmail from the python script from the webbrowser.

here is my code.

def sendMail(name, email) :

MAIL = "/usr/sbin/sendmail"
ADDRESS = '%s'%(email)
# get the email message from a file
mssg = "Hello %s, \n This is a test email"%(username)

# open a pipe to the mail program and
# write the data to the pipe
p = os.popen("%s %s" %(MAIL,ADDRESS), 'w')
exitcode = p.close()
if exitcode:
print "Exit code: %s" % exitcode

this works in a python shell but not from the webbrowser. i suspect the path to sendmail is the problem.

how do i get sendmail to work from apache, do i have to add it to some sort of path variable? does apache have its own sendmail functions i can use? or python it self have a better alternative.

im new to all of this so please be gentle

Old 06-06-2005, 11:26 AM   #2
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Hmm...python shouldn't really have any trouble accessing sendmail, when run as a cgi program from cgi-bin. Are you getting any error messages, or is it simply not working? Do you have python's debugging turned on

import cgitb
cgitb.enable(display=1) #On, 0 is off

and is it giving any helpful information?
Old 06-07-2005, 04:31 AM   #3
Registered: Oct 2003
Distribution: College Linux 2.3
Posts: 43

Original Poster
Rep: Reputation: 15
no will try that tho and see what i get,

i get an exit code of

"Exit code: 17152"

i added the debug stuff at the top of the page and i dont get an error page up as i would expect if something went wrong

Last edited by hurricane; 06-07-2005 at 05:01 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
php+ sendmail no good - python + sendmail ok nephish Linux - Networking 1 10-07-2005 01:19 PM
Installing the Python om my Apache 1.3.3 webserver CPUFreak91 Linux - Software 1 09-02-2005 08:09 PM
Apache and Python... HOW Dark Carnival Programming 0 12-25-2003 06:58 PM
Apache and python WiWa Linux - Newbie 0 08-13-2003 03:57 PM
Apache and mod_python not exec python scripts fIREfox Linux - Networking 1 02-11-2003 05:54 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration