NYCPHP Meetup

NYPHP.org

[nycphp-talk] custom mail() with attachment problemusingRH7.3/Apache

drydell at att.net drydell at att.net
Fri Jun 11 14:32:07 EDT 2004


I've never had much luck using \r\n in HTTP or email headers either - just at the beginning MIME header... this snippet is from my email class, wich has never given me any problems:


 if (count($this->attach) > 0) {
    $mime_boundary = "==Multipart_Boundary_".md5(uniqid(""));
    $headers = "\r\nMIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"$mime_boundary\"";
    $message = "This is a multi-part message in MIME format.\n\n";
    $message .= "--$mime_boundary\n";
    $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
    $message .= "Content-Transfer-Encoding: 7bit\n\n$email_msg\n\n";
    $message .= "--$mime_boundary\n";
    foreach ($this->attach as $filename => $fileArray) {
       $message .= "Content-Type: {$fileArray['type']};\n name=\"{$filename}\"\n";
       $message .= "Content-Disposition: attachment;\n filename=\"{$filename}\"\n";
       $message .= "Content-Transfer-Encoding: base64\n\n{$fileArray['data']}\n\n";
       $message .= "--$mime_boundary\n";
    }
 }


> 
> Well, here's one for the books.. "\r\n" fails (email is either mangled 
> or never sent at all!), but "\n" works just fine! 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040611/aa77c2c2/attachment.html>


More information about the talk mailing list