Anyone want to give good examples of what headers to use when sending email using mail() so that email gets accepted from more then less people.

Seems to me that headers play a large part if email is to be put in inbox instead of trash or treated as spam.

Some good examples and why would be nice.

    Yes headers are a key part in your email being delivered because they transmit the information about the email itself. Where it came from, what its labeled as, ect.

    These are the headers i use to get about a 95% delivery rate.

    // setup headers for mail
    $headers = '';
    $headers .= "From: messages@yoursite.com\n";
    $headers .= "Reply-To: messages@yoursite.com\n";
    $headers .= "Date: " . date("r") . "\n";
    $headers .= "Return-Path: messages@yoursite.com\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Message-ID: " . date("r") . "globale@globale\n";
    $headers .= "Content-Type: text/html;charset=iso-8859-1\n";
    $headers .= "X-Priority: 1\n";
    $headers .= "Importance: High\n";
    $headers .= "X-MXMail-Priority: High\n";
    $headers .= "X-Mailer: PHP Mailer 1.0\n";
    

    Hope this helps.

      what is this header ?
      $headers .= "Message-ID: " . date("r") . "globale@globale\n";

      Not sure what the globale@globale is

        Quoting RFC 822:

        This field contains a unique identifier (the local-part
        address unit) which refers to THIS version of THIS message.
        The uniqueness of the message identifier is guaranteed by the
        host which generates it. This identifier is intended to be
        machine readable and not necessarily meaningful to humans. A
        message identifier pertains to exactly one instantiation of a
        particular message; subsequent revisions to the message should
        each receive new message identifiers.

          so do i change globale@globale to something else
          Still not sure on that..

            Usually, you want it to be:

            some unique string@server name

            So, for example:

            $msg_id = md5(uniqid(rand(), true)) . '@' . $_SERVER['SERVER_NAME'];

            would probably be what I'd use.

              Use what brad recomended ..

              I use date( "r" ) . 'globale@globale';

              b/c i havent been sending out very many mails .. and globale is the name of my machine ...

              Hope this helps.

                So one would do this if I did this correctly

                $msg_id = md5(uniqid(rand(), true)) . '@' . $_SERVER['SERVER_NAME'];
                
                $headers .= "Message-ID: " . date("r") . "" . $msg_id . "\n";
                

                Did I use those quotes correctly there ?

                  Just $msg_id would be fine, forget the date(" r ")

                    slimjim wrote:

                    Did I use those quotes correctly there ?

                    Well, the . "" . is superfluous and not-needed, but as Sayian suggested, simply sticking with the $msg_id will be random enough.

                      Write a Reply...