Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jumpersknee

macrumors newbie
Original poster
Jan 5, 2006
2
0
North Dakota
Anybody know how to congifure mail in
php so that it works? Running Panther and using
localhost so I can mess with my configure files.

Tried this code and nothing happens.
Thanks for the help!

<?php

//Some variables
$mymail = "jumpersknee@bis.midco.net";
$ename = $_POST['ename'];
$eemail = $_POST['eemail'];
$esubject = $_POST['esubject'];
$emessage = $_POST['emessage'];
$eip = $_POST['eip'];

//Function to check email address
function checkemail($eemail) {
if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$eemail)) {
return true;
}
else {
return false;
}
}

//Mail Processing
if ($_POST['esubmit']) {
//Check for blank fields
if ($ename == "" || $eemail == "" || $esubject == "" || $emessage == "") {
echo "<p>It appears that you left a blank field.<br/> Please make sure you fill everything in.</p>";
}
//Check to see if the email address is valid
else if (checkemail($eemail) == false) {
echo "<p>It appears that you enter an invalid email address.<br/> Please check your email again.</p>";
}
//Send the email if there's no error
else {
$body = "$emessage\n\nName: $ename\nEmail: $eemail\nIp: $eip";
mail($mymail,$esubject,$body,"From: $eemail\n");
echo "<p>Thank you for your email $ename!</p>";
}
}

?>
 
jumpersknee said:
Anybody know how to congifure mail in
php so that it works? Running Panther and using
localhost so I can mess with my configure files.

..SNIP..

?>

I didn't look too close at the code but I suspect you need to enable postfix.

The easiest way of doing this is via PostfixEnabler if you are using Panther or MailServe for Tiger.

You can enable Postfix without spending any money but you'll have to do a reasonable amount of homework (macosxhints.com is a good starting place and Webmin is a free and fantastic tool that can help ).

One thing to look out for is the fact that a lot of ISP's will block outgoing mail from your Mac as protection against Spam - so you may need to set up Postfix to use an existing email host.

Hope this lot of waffle is of some use - I'm no expert!
 
Are you sure that the script actually gets all the way down to execute the mail() function?

Try making a very easy php script:
Code:
<?php
$mymail = "<your mail address>";
$esubject = "Test";
$body = "Body";
$eemail = "<your mail address>";
$sent = mail($mymail,$esubject,$body,"From: $eemail\n");
if ($sent) echo "Sent a mail to ".$mymail;
else echo "Couldn't send mail...?";
?>

And see if it still does nothing... :)
 
And one other thing -

Open up 'Console' (Applications->Utilities), and examine the /var/log/mail.log file. That can give a lot of clues.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.