I’ve found several tutorials on how to do this, but it doesn’t work. Here’s my simple emailing code:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$zone = $_POST['zone'];
$call_time = $_POST['call_time'];
$comment = $_POST['comment'];
$to = 'MY EMAIL';
$subject = '$name is interested in your product!';
$message = 'name = $name\nemail = $email\nphone = $phone\ntimezone = $zone\nbest time to call = $call_time\nmessage = $comment';
if(mail($to, $subject, $message))
{
echo "The information was successfully sent.";
}
else
{
echo "The information was NOT sent.";
}
?>
(Once I get it working I’ll beef up the security)
So any ideas why this isn’t working? I get the success message, but not the email.
Ok, so I guess I could have been more specific:
- I’m running Mac OS X
- I’m currently testing my site on MAMP (a local Apache, MySQL, and PHP server-thingy :D)
- Obviously I put a valid email in the “to” field.
- When I write the errors to a log file, I don’t see any
I’m running Mac OS X
PHP is probably handing off the email to your local smtp server (I think it’s postfix) successfully. That will give you your success message. And probably, postfix on your computer is not configured to actually send email out successfully. Or port 25 is blocked by your ISP. Or something else on the email server side.
Your PHP is fine. I think you have a SMTP server configuration issue to work out.