Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Special Interests > Web Design and Development
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 5, 2006, 11:33 PM   #1
jumpersknee
macrumors newbie
 
Join Date: Jan 2006
Location: North Dakota
Configure Mail in PHP

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 is offline   Reply With Quote
Old Jan 8, 2006, 11:55 AM   #2
littlejim
macrumors regular
 
Join Date: Jan 2002
Location: Bob Fossils Zooniverse
Quote:
Originally Posted by jumpersknee
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!
__________________
Blue Pants, Blue Pants, I've got baby Blue Pants. The Mighty Boosh
I Audioscrobble
littlejim is offline   Reply With Quote
Old Jan 8, 2006, 12:08 PM   #3
Mitthrawnuruodo
Demi-God (Moderator)
 
Mitthrawnuruodo's Avatar
 
Join Date: Mar 2004
Location: Bergen, Norway
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...
__________________
Those who fail to learn history are doomed to repeat it;
those who fail to learn history correctly...
why, they are simply doomed.
Mitthrawnuruodo is online now   Reply With Quote
Old Jan 8, 2006, 12:12 PM   #4
littlejim
macrumors regular
 
Join Date: Jan 2002
Location: Bob Fossils Zooniverse
And one other thing -

Open up 'Console' (Applications->Utilities), and examine the /var/log/mail.log file. That can give a lot of clues.
__________________
Blue Pants, Blue Pants, I've got baby Blue Pants. The Mighty Boosh
I Audioscrobble
littlejim is offline   Reply With Quote

Reply

Mac Forums > Special Interests > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 2002-2009, MacRumors.com, LLC