Forum Moderators: coopster

Message Too Old, No Replies

sendmail - launch php process

         

MikeOtown

9:32 pm on Jun 6, 2003 (gmt 0)

10+ Year Member



I need to figure out a way to store outgoing e-mails in our MySQL database. If I need to write code, I'd like to do it in PHP. Does anyone know how this can be done? The server OS is Red Hat Linux. Is there a way to spawn a PHP script everytime a mail sent from our server?

willybfriendly

10:09 pm on Jun 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is pretty easy to implement. Are your outgoing emails auto generated? If not, look for a freeware PHP script, there are several. If they are auto generated replies, as in a response to a contact form, storing the contact information can be done with only a few lines of code.

Bring this question over to the PHP/PERL forum and I am sure you will get lots of help.

WBF

dingman

10:34 pm on Jun 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you mean you need to start this PHP script whenever the mail server sends a message, regardless of the source of that message, or just when one is sent from the web site?

If the first, exactly how to trigger the script will vary depending on what mail server software you use. I think Red Hat still defaults to Sendmail - a mail server which can do anything, but about whose configuration I know relatively little. Regardless of the mail server, this approach would require a PHP script that can be executed from the command line rather than from the server. Conveniently, this is possible. Instead of your usual PHP script with lots of HTML in the middle, just do something like this:


#!/usr/bin/php
<?php
// PHP Code
?>

Then make the file executable, probably with 'chmod ug+x <filename>' or 'chmod a+x <filename>'.

Now you just have to figure out how to make your mail server call <filename> every time it sends a message out. For that piece of the puzzle, you might want to hop on over to the Linux, Unix, and *nix like Operating Systems [webmasterworld.com] forum. Feel like a ping-pong ball yet?

MikeOtown

2:42 pm on Jun 9, 2003 (gmt 0)

10+ Year Member



>> Now you just have to figure out how to make your mail server call <filename> every time it sends a message out.

This is the part I need help with. Any ideas?