Skip to content

Wrong HTML charset iso-8859-1 if no attachments are added #29

Description

@schorschii

I'm using the following code:

$mime = new Mail_mime("\r\n");
$mime->setHTMLBody(' öäü ');

$mail = Mail::factory('sendmail');
$mail->send($email,
	$mime->headers([
		'From' => 'test@example.com',
		'Subject' => '=?UTF-8?B?'.base64_encode("my subject").'?=',
	]),
	$mime->get([
		'text_encoding' => '7bit',
		'text_charset'  => 'UTF-8',
		'html_charset'  => 'UTF-8',
		'head_charset'  => 'UTF-8',
	])
);

But I erroneously receive an email with Content-Type: text/html; charset=ISO-8859-1 header and <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">, and therefore the special chars are broken.

The interesting part now is when adding an attachment (following code), the HTML charset is now suddenly correctly set to UTF-8 in the header and <meta> tag!

$mime->addAttachment(
	'BEGIN:VCALENDAR ...',
	'text/calendar', 'calendar-event.ics', false, 'plain'
);

Can somebody tell me if I'm doing anything wrong with the UTF-8 encoding or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions