Welcome to WebmasterWorld Guest from 54.147.63.124

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

send mail php error

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

Junior Member

5+ Year Member

joined:May 4, 2010
posts: 60
votes: 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!


<?php
$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)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 0


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");
}
else{
//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.

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

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Apr 30, 2007
posts:1394
votes: 0


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)

Junior Member

5+ Year Member

joined:May 4, 2010
posts: 60
votes: 0


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