PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #8386

HTML body not correctly encoded if attachments present

Details

Submitted2006-08-08 11:01 UTC
Fromlucabert at lucabert dot de
Assignedcipri
StatusClosed
PackageMail_Mime
PHP Version4.3.5
OSLinux RedHat 9
Roadmaps1.4.0, 1.4.0a1

Comments

[2006-08-08 11:01 UTC] lucabert at lucabert dot de

Description:
------------
If an E-Mail has attachments, it seems not to encode the HTML part.
Many Mailer have problem to display the message.

Test script:
---------------
<?
include('Mail.php');
include('Mail/mime.php');

$mime = new Mail_mime("\n");
$mime->setTXTBody('Das ist ein Test');
$mime->setHTMLBody('<HTML><BODY><H1>Das ist ein TEST</H1></BODY></HTML>');
$mime->addAttachment('/tmp/test.gz', 'application/x-gzip', 'test.gz');

$hdrs = array(
'From' => 'Luca Bertoncello <lucabert@server.de>',
'To' => 'lucabert@server.de',
'Subject' => 'Ein kleines Test',
'Message-Id' => '<'.date('YmdHis').'.'.posix_getpid().'@localhost>',
'Date' => date('r')
);

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('smtp', array('host' => 'localhost', 'auth' => 'CRAM-MD5', 'username' => '<my Username>', 'password' => '<my Password>', 'localhost' => 'server.de'));
$ret = $mail->send('lucabert@server.de', $hdrs, $body);
?>

Expected result:
----------------
This is a normal HTML E-Mail with an Attachment:

Subject: HTML mit 2 Attachments
From: Luca Bertoncello <lucabert@server.de>
To: lucabert@server.de
Content-Type: multipart/mixed; boundary="=-FssUx3EEijD6zZ/ed9KI"
Message-Id: <1154341815.5647.1.camel@lucabert>
Mime-Version: 1.0
X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2)
Date: Mon, 31 Jul 2006 12:30:15 +0200

--=-FssUx3EEijD6zZ/ed9KI
Content-Type: multipart/alternative; boundary="=-X5H4pZuJcQ+po6ZfSGQ3"

--=-X5H4pZuJcQ+po6ZfSGQ3
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Und HTML dazu

--=-X5H4pZuJcQ+po6ZfSGQ3
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.0.10">
</HEAD>
<BODY>
Und <FONT COLOR="#3366ff"><B><I><U><S>HTML</S></U></I></B></FONT> dazu
</BODY>
</HTML>

--=-X5H4pZuJcQ+po6ZfSGQ3--

--=-FssUx3EEijD6zZ/ed9KI
Content-Disposition: attachment; filename=test.gz
Content-Type: application/x-gzip; name=test.gz
Content-Transfer-Encoding: base64

H4sICHLbzUQAA3BpcHBvAAsoyi9L5AIAtFpUkQYAAAA=

--=-FssUx3EEijD6zZ/ed9KI--

Actual result:
--------------
And this is what I get with the script:

MIME-Version: 1.0
From: Luca Bertoncello <lucabert@server.de>
To: lucabert@server.de
Subject: Ein kleines Test
Message-Id: <20060808123727.19652@localhost>
Date: Tue, 8 Aug 2006 12:37:27 +0200
Content-Type: multipart/mixed;
boundary="=_ecadccd86e007f0fabc3b902aa72fbeb"

--=_ecadccd86e007f0fabc3b902aa72fbeb
Content-Type: multipart/alternative;
boundary="=_e5f0bb1e2fb2b32f9a165a2837a330cf"

--=_e5f0bb1e2fb2b32f9a165a2837a330cf
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit

Das ist ein Test
--=_e5f0bb1e2fb2b32f9a165a2837a330cf
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML><BODY><H1>Das ist ein TEST</H1></BODY></HTML>
--=_e5f0bb1e2fb2b32f9a165a2837a330cf--
--=_ecadccd86e007f0fabc3b902aa72fbeb
Content-Type: application/x-gzip
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.gz"

H4sICHLbzUQAA3BpcHBvAAsoyi9L5AIAtFpUkQYAAAA=
--=_ecadccd86e007f0fabc3b902aa72fbeb--

The Problem is that, betwenn the 2 boundaries after HTML, there is NO newline!