Darwin's SendMail script under OsX (thru php on apache)

Page may contain affiliate links. Please see terms for details.

Spinal

MB Enthusiast
Joined
Sep 14, 2004
Messages
4,806
Location
between Uxbridge and the Alps
Car
x254, G350, Duster, S320, Mach1, 900ss and a few more
Howdy! First and foremost, if you clicked on this thread; congratulations! You are either curious enough to wonder what the acronyms mean - or you know what they mean and may be able to help me! Either way... keep reading!

I've enabled PHP and mysql on one of the boxes I'm administering. The box runs as an internal-website (i.e. DNS entry on our internal DNS server, but no port forwarding specifically to the box so the outside world can't "see" the box).

The box runs OsX (10.4.8); apache (some version) (neither installed by me) - and now Apache's php and mysql add-ons. I configured php and mysql this afternoon, and both are working quite happily. php I did as such (in httpd.conf)


Uncommented:
LoadModule php4_module libexec/httpd/libphp4.so
AddModule mod_php4.c

Added:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule mod_dir.c>
DirectoryIndex index.html index.php index.htm
</IfModule>

Now, I typed up a quick html page; something on the lines of:
<form method="get" action="sendmail.php"><br />
Email: < input name="email" type="text" /><br/>
Message:<textarea name="message" rows="10" cols="30"></textarea><br />
<input type="submit" /></form>

and a quick php script:
<?$email = $_GET['email'] ;
$message = $_GET['message'] ;

mail( "***@***-england.co.uk", "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";
?>

(the *** replace my email at work)

Now, if I give the whole thing a blast, it happily replies with "Congratulations your email has been sent" - which is good... php hasn't crashed, no errors, bla bla...

BUT... nothing ever comes through on the mail client side... I've tried alternative email addresses... nada... My first idea was that as the box is behind a proxy, the proxy might be filtering everything out (the proxy is set up in such a way that EVERYTHING needs to go through a specific IP:pORT to get to the outside world)... But the box is configures to go through that proxy (and can connect to the net). Does apache or unix's sendmail need their own proxy configs?

If not, any ideas? I'm at a total loss...

Michele
 
I'm not a PHP or Sendmail expert but have some OS X knowledge

Are you using PHP or Sendmail or both to send the mail?

What do the logs say? Are you running OSX or OSX server? Is this the Apple-installed Apache?

The success message suggests the mail was sent but not received. I'd check the PHP and Sendmail logs (and increase the logging verbosity if needed) and also make sure the sender has permissions to send. Most OS X failures of this kind are due to incorrect permissions

One way to test might be to send to a mailserver & mail client on the same machine - that will mean you're not testing firewalls & proxies at the same time.

Nick Froome
www.w124.co.uk
www.pvision.co.uk
 
Howdy!

eGuru: Posted there, thanks! Now waiting for a reply!

bolide: I'm using PHP's mail() function, which invokes the sendmail function (which is pre-build in *nix operating systems). The box is running OsX standard (not server), with Apple's Apache and PHP.

I wanted to increase the sendmail logs, (or put it in debug mode, whichever) but I can't find out how... sendmail is in:
/usr/sbin/
if I remember correctly (not at work yet).

I thought of permissions as Apple has defied the "standard" and had messed up the permissions putting sendmail in a group modifyable folder (BIG no-no, sendmail is not a happy camper in 10.2/10.3); but they seem to have corrected this in 10.4.

I'll tinker a little more this afternoon - at worst everything goes into a table and the IT team is forced to have a query to that table as their home page (just kidding...)

Thanks again,
Michele
 
OK - I'm not a PHP person.... but have you checked that yuo can send mail from the mac (try telnet or - can't remember the mac version....) - this will narrow it down to PHP script.......


It sounds like you have good security there... so I'm thinking you may have a working script, but bad conectivity....
 
I can think of two possibilities here.

1. sendmail isnt even being invoked. If you have total control of the machine, you can check this by replacing the real sendmail binary with a shell script that will simply log the arguments, eg:

#!/bin/sh
exec >> /tmp/sendmail.log 2>&1
echo sendmail called by pid $$ with args $*
ps -ef
exit 0

Then check /tmp/sendmail.log. You can lookup the PID against the ps in the list to check its your php/apache process. Obviously put the original sendmail back once youve tested this, or it will never work.

2. sendmail isnt configured correctly (via sendmail.cf file) to send mail outside of the local machine. If you send mail from the command line, does it arrive?

i.e.

echo hello | mail [email protected]

Good luck
 
Thanks! I'll try tomorrow, my thoughts keep narrowing towards sendmail's configs...

Busy busy days! Its scary, when you give the people you "should trust" (i.e. the IT team) admin priviledges... all hell breaks loose!

From now on, I'm keeping the root password to myself; everyone else is getting restricted accounts! (This is my daily rant regarding the mysql database :p)

Thanks again,
Michele
 

Users who are viewing this thread

Back
Top Bottom