zero-perfoliate
zero-perfoliate

Author Topic: Mail Function - all headers, no message  (Read 277 times)

Offline mulderthe23rd

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Mail Function - all headers, no message
« on: May 16, 2010, 05:09:27 PM »
Alright, so:

<?php
//  recipient
$to  = 'xxxxxxxxxxxxx' ;

// subject
$subject = 'Ask the Marauders';

$name = $_POST['yourname'];
$email = $_POST['email'];
$for = $_POST['for'];
$txt = $_REQUEST['txt'];

$message = "
Name: $name \n\n
Email: $email \n\n
For: $for \n\n
Txt: $txt \n\n
";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= "To: Infamous Marauders <xxxxxxxxxxxxxx>" . "\r\n";
$headers .= "From: $name <$email>" . "\r\n";

mail($to, $subject, $message, $headers);
header("Location: thankyou.htm");
?>


This is a mail function that is supposed to allow users to type in a message that I can read and reply to, including their name and email address so that I can do so. However, when it sends, all I see are the headers. No message at all. I don't know if this is a simple n00b error, or if the code is messed up. I simply don't know. I was trying to get someone to help me with this, and after getting to this set of code, they left me high and dry. Admittedly I've struggled to learn PHP for two years. (Key word: struggled.) I'm not very good at it. Anybody here want to give it a go?

Offline Sergey Popov

  • PHP Helpers
  • ***
  • Posts: 31
  • Karma: +0/-0
    • Freelance PHP Developer
Re: Mail Function - all headers, no message
« Reply #1 on: May 20, 2010, 01:57:41 AM »
What is your system - Linux or Windows? You can try to eliminate \r from header (just leave all \n ).
Refer to php documentation or PHP Help forum for more info and for answers to your questions