homepage Welcome to WebmasterWorld Guest from 54.196.168.78
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
send mail php error
laurasamps




msg:4217076
 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!


<?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




msg:4217090
 10:11 am on Oct 15, 2010 (gmt 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

enigma1




msg:4217162
 1:39 pm on Oct 15, 2010 (gmt 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';

laurasamps




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved