I recently created my comapny website which, with a membership system, sends out a welcome HTML message when you register and also ( if requested ) sends out a monthly sale catalogue ( a word .doc file).
So I created all the code for this specifying all the headers & using the mail() function etc etc. After a while a couple of complaints came back from people saying the .doc file was unencoded garble. This confused me as testing it to my own email address it worked fine. After checking the file encoding method which was ("application/msword") and generally asking around I couldnt see any problem. So I changed the system to use the PEAR classes think it would create less room for error with all those '/r/n' gone.
After implementation I'm still having problems below is an example of how I would send out a catalogue using the PEAR Classes.
Note/ for readability two arrays; $row, containing customer details and $saledetails, containing sale detals
Code: Select all
$mail_to = $row['email'];
$mail_subject = $saledetails['SaleType'] . " Sale catalogue " . $saledetails['SaleNumber'];
$mail_body = "Dear " . $row['title'] . " " . $row['surname'] . ",\r\n\r\n";
$mail_body .= "As requested, attached is the catalogue for our upcoming " . $saledetails['SaleType'] . " sale to be held on " . date("l dS of F Y",$SaleDate) . "\r\n\r\n";
$mail_body .= "Yours Sincerely\r\n\r\n";
$mail_body .= "Online Services\r\n\r\r";
$catalogue_filename = "../Catalogues/" . $_POST['SaleNumber'] . ".doc";
$hdrs = array('From' => 'online.services@denhams.com','Subject' => $mail_subject);
// Declare Mime Object
$crlf = "\r\n";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($mail_body);
$mime->addAttachment($catalogue_filename,"application/msword");
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
$mail_result = $mail->send($_POST['email_override'], $hdrs, $body);