I am trying to send emails with an attachment using htmlMimemail 2.5.1 (PHP5 isn't supported by my webhost...yet). I can send HTML and text emails fine until I insert the code to add the attachment. Here is what I'm working with to email file "fileatt":

require_once("htmlMimeMail.php");

// Read POST request params into global vars
$to = $POST['to'];
$from = $
POST['from'];
$subject = $POST['subject'];
$body = $
POST['body'];

// Obtain file upload vars
$file = $FILES['fileatt']['tmp_name'];
$file_type = $
FILES['fileatt']['type'];
$file_name = $_FILES['fileatt']['name'];

// Instantiate a new HTML Mime Mail object
$mail = new htmlMimeMail();

// Set the From and Reply-To headers
$mail->setFrom("Webmaster <$from>");
$mail->setReturnPath($from);

// Set the Subject
$mail->setSubject($subject);

$html = $body;
$text = $body;

// Create the HTML email
$mail->setHTML($html,$text);

// Attach file attachment
$attachment = $mail->getFile($file);
$mail->addAttachment($attachment, $file_name, $file_type);

// Send the email
$result = $mail->send(array($to));

The email is sent, but what I get looks like this:

--=_562d1b7edd5a713a20112a3f0b7a077b
Content-Type: application/pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Nitrogen balance.pdf"

JVBERi0xLjMNJeLjz9MNCjIyIDAgb2JqDTw8IA0vTGluZWFyaXplZCAxIA0vTyAyNCANL0ggWyAx......

I've spent hours on this and can't figure out what is wrong.

Any help/suggestions would be appreciated. I would prefer to stay with htmlMimemail since I've already installed it.

MLC

    Write a Reply...