php mail problem

Discussion in 'Programming' started by dizyn, Dec 16, 2008.

  1. #1
    When i send an email I want to set from and after Hi i want text to move to next line.

    I am sending mail on hotmail for test purpose. I don't want to use html content type

    Can anyone help me out?

    thanks in advance.

    				$to = $_POST["email"];
    				$subject = 'Your Password';				
    				$message = 'Hi \n'. 'Your new password is:'.$substr;				
    				$headers  = 'MIME-Version: 1.0' . "\r\n";
    				$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";	
    				$headers .= contactus . "\r\n";
    				mail($to, $subject, $message, $headers);
    
    PHP:
     
    dizyn, Dec 16, 2008 IP
  2. Yesideez

    Yesideez Peon

    Messages:
    196
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $to = $_POST['email'];
    $subject = 'Your Password';    
    $message = "Hi\n\n".'Your new password is:'.$userpassword;
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";    
    $headers .= 'From: Site Name <site@email.com>' . "\r\n";
    $headers .= 'Reply-To: Site Name <site@email.com>' . "\r\n";
    mail($to, $subject, $message, $headers);
    PHP:
    I changed $substr to $userpassword because substr is a PHP function.

    Anything inside single quotes is used exactly - \r\n will be shown as that. You'll need to use double quotes which I changed it to.

    I don't know what was in "contactus" but I removed this and replaced it with declaration of "from" and "reply to" - the latter if missing can be prone for Hotmail to dump it into their junk inbox.

    Lastly, I changed the $_POST to use single quotes.
     
    Yesideez, Dec 16, 2008 IP