Help with php mail

by 8 replies
8
Hi Everybody

Please I want to know how can I specify header parameters using mail() function

I want to set and usemy own email header, plz tell me how can I do it? like specify "From Name", "Mail From", "Reply-To", "Returnpath", etc..

now I can set just: to, message, subject

Thank a lot
#programming #@@@help #mail@@@ #php
  • [DELETED]
  • Try this:

    $email = "email@example.com";
    $subject = "My Subject";

    $header = 'MIME-Version: 1.0'."\r\n";
    $header .= 'Content-type: text/html;charset=iso-8859-1'."\r\n";
    $header .= "Reply-To: My Name <myemail@example.com>\r\n";
    $header .= "Return-Path: My Name <myemail@example.com>\r\n";
    $header .= "From: My Name <myemail@example.com>\r\n";
    $header .= "Organization: MyOrganization \r\n";
    $body = "HTML MESSAGE BODY HERE";

    mail($email,$subject,$body,$header);
    • [1] reply
  • $from=$_POST['from'];
    $headers .= "From: ".$from." <some@email.here>\r\n";
  • I try this but not works, plz I want to set the From name as a input, this is the code:

    <?php

    $to=$_POST['to'];
    $subject=$_POST['subject'];
    $message=$_POST['message'];

    $From=$_POST['From'];

    $headers .= 'From: $From' . "\r\n";

    $headers .= "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=ISO-8859-1" . "\r\n";
    $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
    $headers .= 'Reply-To: mailhere' . "\r\n";


    if($_POST['submit']) {

    mail($to,$subject,$message,$headers);

    echo "message sent";
    }


    ?>
    [/B]
  • Try this:

    <?php
    if(isset($_POST['submit'])) {
    $to=$_POST['to'];
    $subject=$_POST['subject'];
    $message=$_POST['message'];
    $From=$_POST['From'];
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=ISO-8859-1" . "\r\n";
    $headers .= "From: ".$From." <some@email.here>\r\n";
    $headers .= "Reply-To: My Name <myemail@example.com>\r\n";
    mail($to,$subject,$message,$headers);
    echo "message sent";
    }else{
    //Your form here
    }
    ?>
    • [1] reply
    • Yes, it's working now, I can put any From name I want, Thank you

      plz How can I add received and returnpath ?
  • $headers .= "Return-Path: some@email.here\r\n";
  • hmm, not worked

Next Topics on Trending Feed