Welcome to WebmasterWorld Guest from 54.196.224.166

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

send mail php error

     

laurasamps

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

5+ Year Member



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");

?>

Matthew1980

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");
}
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

enigma1

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';

laurasamps

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

5+ Year Member



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