Results 1 to 2 of 2

Thread: mail() not sending when adding headers.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    326

    Question mail() not sending when adding headers.

    I have a script that gets email addresses from a db and sends them. I can send them and have clients receive them when there are no headers sent with it. but I want to send html emails also so I need headers and when I send it that way the clients never receive the email and I dont get any errors.

    PHP Code:
    $boundary md5(uniqid(time()));

    $headers  'From: ' $from "\n";
    $headers .= 'To: ' $myrow[email] . "\n";
    $headers .= 'Return-Path: ' $from "\n";
    $headers .= 'MIME-Version: 1.0' ."\n";
    $headers .= 'Content-Type: multipart/alternative; boundary="' $boundary '"' "\n\n";
    $headers .= $message "\n";
    $headers .= '--' $boundary "\n";
    $headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
    $headers .= 'Content-Transfer-Encoding: 8bit'"\n\n";
    $headers .= $message "\n";
    $headers .= '--' $boundary "\n";
    $headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' ."\n";
    $headers .= 'Content-Transfer-Encoding: 8bit'"\n\n";
    $headers .= $message "\n";
    $headers .= '--' $boundary "--\n";

    $mailOk=mail(''$subject,''$headers); 
    Anyone have any ideas why?

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: mail() not sending when adding headers.

    You need to use the carrige return / linefeed combination to separate headers "\r\n". You should also add to the message argument "This is an MIME Encoded message".

    Also, Return-Path cannot be set. This is set by the SMTP server and thus you need to set the sendmail_from PHP.ini setting using the init_set() function to change this to the value you wish.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width