Problem with PHP email handler

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adsparrow
Forum Newbie
Posts: 1
Joined: Sun Mar 30, 2014 7:45 am

Problem with PHP email handler

Post by adsparrow »

Hi All,

This was working and I never changed anything and now all of a sudden its not working. Here is my PHP:

Code: Select all

<?php

$emailTo = "d.sparrow@cox.net";
$name = $_POST["name"];
$company = $_POST["company"];
$phone = $_POST["phone"];
$emailFrom = $_POST["email"];
$message = $_POST["message"];
$subject = "New message from Too Neat Studios";

if( !empty( $_POST ) ) {
	$body  = "Name: " . $name . "\n\n";
	$body .= "Company: " . $company . "\n\n";
	$body .= "Phone: " . $phone . "\n\n";
	$body .= "Email: " . $emailFrom . "\n\n";
	$body .= "Message:\n" . $message;
	$body  = wordwrap($body, 70);
	$header = "From: " . $emailFrom . "\nReply-To: " . $emailFrom. "\n\n";
	
	if( mail( $emailTo, $subject, $body, $header ) ) {
		echo( "result=Successful" );
		
	} else {
		echo( "result=Unsuccessful" );
	}
}

?>
when i submit the form I get a result=Successful back, but I never get the email, and like I said it was working a few weeks ago and I didn't change anything??
And I'm receiving emails from elsewhere so I know my email is working.... Any Ideas?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Problem with PHP email handler

Post by Celauran »

mail() returning true doesn't necessarily mean the mail was delivered. Check your mail server logs and go from there.
Post Reply