...

View Full Version : mail() not working properly



rafiki
08-31-2006, 08:15 PM
<?php
$to = "west.jamie@gmail.com";
$subject = "Jamie Wests Survey Results";
$header = "from west.jamie@gmail.com 'X-Mailer: PHP/' . phpversion();";
$message = "NAME: {$_POST['firsname']} {$_POST['surname']} DOB:{$_POST['dob']} Year in school:
{$_POST['year_school']} siblings: {$_POST['siblings']} bedtime: {$_POST['dob']} homework time:
{$_POST['homework']} tv time: {$_POST['tv']} computer time: {$_POST['computer']}
family time: {$_POST['family']} time with friends: {$_POST['friends']}";
$message = wordwrap($message, 70);
mail($to, $subject, $header, $message);
?>

it sends me the email, but misses out some of the message, anybody got any idea y?

rafiki
08-31-2006, 08:18 PM
heres the email it sends me :S

4 hours tv time: 2 hours computer time: 6 hours
family time: 7 hours time with friends: 7hours
X-MM-Mail-From-Script: /jaysphp/welcome.php
X-Complains-To: abuse@lycos.co.uk
X-MM-Mail-From-IP: xxx.xx.xx.x (is acutall IP in here not the *'s)
Errors-To: jaysphp@lycos.co.uk

GJay
08-31-2006, 08:44 PM
you have the wrong argument order for mail()
http://php.net/mail

are you trying to include the output from php_version(); in the header? you need to take it outside the string.
I normally use 'From: email@example.com' (note the colon,:), and things work- not saying for sure that's necessary though.
if you put the arguments in the right order, and skip the additional paramaters (i.e. $header) for now, what happens?

rafiki
08-31-2006, 11:45 PM
took out $headers and still same result, any more ideas?

managedinternet
08-31-2006, 11:51 PM
Use This
$name , $message & $email are values passed from the form on a previous page


<?php
$emailto = "Recipient Address";
$ToSubject = "Subject Here";
$headers = "From: $name <$email>\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$EmailBody = "$name - $email<br>";
$EmailBody .= "sent this message.<br>";
$EmailBody .= "<br>";
$EmailBody .= "$message";
mail($emailto,$ToSubject,$EmailBody,$headers);
if(mail){
header("Location: thanks.php");
}
?>

managedinternet
08-31-2006, 11:52 PM
any variable with the same name like $message that appears more than once needs a . before =

example

$message = "Hello";
$message .= "This is my";
$message .= "Message To You";

rafiki
09-01-2006, 12:12 AM
managed thanks for the quick reply, i tried ur solution still didnt send all data, i have fixed it (was typos lol)

managedinternet
09-01-2006, 12:33 AM
no problem



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum