Mail_mime and attachements
| From: | Mark Heintz PHP Mailing Lists | Date: | Tue, 01 Jul 2003 17:58:52 +0000 |
| Subject: | Mail_mime and attachements | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-6366@lists.php.net to get a copy of this message | ||
I'm attempting to send an email with a single attachment (doc, pdf, or the
like) using Mail_mime (most recent version via go-pear). While the script
successfully sends out the email with the attachment, the base64 encoded
attachment appears in the body of the message when viewed by the client
(outlook, mozilla). A search of the list archives turned up similar
problems:
http://marc.theaimsgroup.com/?l=pear-general&m=105250877019887&w=2
http://marc.theaimsgroup.com/?l=pear-general&m=105099147519094&w=2
However, neither of these have any responses/follow-ups.
A sample of the code and resulting email follows. Am I missing
something? I'm not too familiar with email headers, but the blank
Content-Type seems odd. Is this attachment-in-body a known problem with
Mail_mime, and if so is there a work-around (or should I just avoid using
Mail_mime in the future)?
Thanks,
mth.
-----------------------------------
require 'Mail.php';
require 'Mail/mime.php';
$headers['From'] = 'from@domain.com';
$headers['Subject'] = 'attach test';
$mime = new Mail_mime;
$mime->setTXTBody('Testing attachment');
$mime->addAttachment('/path/to/some.doc', 'application/octet-stream');
$hdrs = $mime->headers($headers);
$body = $mime->get;
$mailer = $& Mail::factory('mail');
$message->send('to@domain.com', $hdrs, $body);
------------------------------------
Return-Path: <httpd@domain.com>
Received: from domain.com (cdm-99-99-99.upstream.com
[99.99.99.99] (may be forged))
by mail.domain.com (8.10.2/8.10.2) with ESMTP id h61HmA302507
for <to@domain.com>; Tue, 1 Jul 2003 12:48:10 -0500
Received: (from httpd@localhost)
by domain.com (8.11.6/8.11.6) id h61He5B04387;
Tue, 1 Jul 2003 12:40:05 -0500
Date: Tue, 1 Jul 2003 12:40:05 -0500
Message-Id: <200307011740.h61He5B04387@domain.com>
To: to@domain.com
Subject: attach test
MIME-Version: 1.0
From: from@domain.com
--=_203a5c29cb726b588b99edab805effa5
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
Testing attachment
--=_203a5c29cb726b588b99edab805effa5
Content-Type:
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="some.doc"
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAUgAAAAAAAAAA
[snip]
--=_203a5c29cb726b588b99edab805effa5