www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP mail() headers

  1. #1
    Join Date
    Mar 2008
    Posts
    60

    Question PHP mail() headers

    I stumbled across a mail script so long ago, I can't remember where. The person who wrote it included a bunch of headers, I might guess every type of header you can possibly use with PHP (but I don't know much about it).

    I'd like to know what headers are necessary and which are recommended, whether or not they're they're in this script I have.

    I'd also like to know if the ini_set line is necessary.

    & if you have any other advice concerning PHP mail, kindly fill me in. Thanks.

    PHP Code:
    $sender_name="";
    $sender_to=$_POST["email"];
    $sender_from=$_POST["sender"];
    $subject=$_POST["subj"];
    $message=$_POST["msg"];

    $to=$sender_to;
    $from=$sender_from;

    ini_set(sendmail_path"/usr/sbin/sendmail -t -f $from");

    $datedate("r");

    $headers "From: $sender_name<$from>\n";
    $headers .= "Reply-To: $sender_name<$from>\n";
    $headers .= "X-Sender: $sender_name<$from>\n";
    $headers .= "X-Mailer: PHP4\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "Content-Transfer-encoding: 8bit\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "X-MSMail-Priority: High\n";
    $headers .= "Importance: 3\n";
    $headers .= "Date: $date\n";
    $headers .= "Delivered-to: $to\n";
    $headers .= "Return-Path: $sender_name<$from>\n";
    $headers .= "Content-Type: text/plain; charset=UTF-8\n";

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

  2. #2
    Join Date
    May 2009
    Posts
    17
    As far as I am aware you only NEED the following. I assume that not including a 'from' address will get you recognised as spam. Anything else is extra. I only use the following for simple scripts.

    PHP Code:
    $to=$_POST["email"];
    $from=$_POST["senders_email"];
    $subject=$_POST["subj"];
    $message=$_POST["msg"];

    $headers "From: $from";

    mail($to,$subject,$message,$headers); 
    Last edited by whirlwind; 09-05-2009 at 04:10 AM. Reason: correction

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles