Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

send mail php error

9:07 am on Oct 15, 2010 (gmt 0)

can anyone see my (probably obvious) mistake here? sorry for posting code but i really am stuck...

its not the security issue im concerned about, its just the actual sending of the mail. the code takes the user to the thank you page, but it does not send the email to our email account. any ideas much appreciated!

$email = $_POST['email'];
$message = $_POST['message'];
$usersname = $_POST['name'];
$company = $_POST['company'];
$position = $_POST['position'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$employees = $_POST['employees'];
$SendEmail ="x@labourprovider.com";

$subject = "Feedback Form Results";

$message = "message from x.com payroll: (".$SendEmail.")\n\r";
$message .= "name ".$usersname."\n\r";
$message .= "Company ".$company."\n\r";
$message .= "Position ".$position."\n\r";
$message .= "Phone ".$phone."\n\r";
$message .= "Email ".$email."\n\r";
$message .= "employees ".$employees."\n\r";

$mailheaders = "content-type: text/plain; charset=UTF-8\r\n";

mail("x@labourprovider.com", $subject, $message, $mailheaders);

header( "Location: x.php");

10:11 am on Oct 15, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

Hi there laurasamps,

Stating the obvious, but have you checked the junk folder of the receiving email account...

As for the code, I can't see anything obvious wrong, you could always do this:

if(mail("x@labourprovider.com", $subject, $message, $mailheaders)){
header( "Location: x.php");
//mail failure

mail() returns a bool on execution, so check to see if it's true or false, then display accordingly..

I would also just echo the contents of $message to see if it gets populated as your expecting.

1:39 pm on Oct 15, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

You need a from header as a minimum either on the server or in the mail code:

$mailheaders = 'From: admin@example.com' . "\r\n" . 'Reply-To: admin@example.com';
1:52 pm on Oct 15, 2010 (gmt 0)

thanks guys, i will give both a go and hope!

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month