Ecodev / newsletter

TYPO3 extension to send newsletter

Home Page:https://extensions.typo3.org/extension/newsletter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UTF8 encoding error in mail subject

KillerDose opened this issue · comments

If I use umlauts in my mail subject, it results in an encryption error when mails are delivered.

screenshot1
screenshot2

There are no errors in the mail texts, only in the subject. I'm not sure if it is my mistake, but i've got this problem nowhere else in my typo3 installation. My database is completely in UTF8 charset and utf8_general_ci collation.

I can solve the problem by simply wrapping $title into utf8_encode in line 130 of Mailer.php, but I'm not sure if this is the best practise solution. If so, I would send a pull request of course.

Had similar symptoms a few months ago for the email body (#120). This may be somehow related, but I'm away from computers and won't be able to confirm that until October.

Usage of utf8_encode() does not sound quite right to me for this case. But if you do submit a PR, be sure to also cover it with (functional?) tests.

Hi,

I also have a problem with title encoding with Yahoo mail - it's ok with other mailing clients.
Here is my newsletter's title : "Les dernières informations et les rendez-vous à venir sur Leucate" and here is the result in Yahoo mail : " Les dernièresà venir sur Leucate".

The title is truncated, here is the source code of the email :

Subject: Les =?utf-8?Q?derni=C3=A8res?= informations et les rendez-vous
 =?utf-8?Q?=C3=A0?= venir sur Leucate

The workaround I found is to change the code in 'Mailer.php' where I encoded the title with base64_encode() :

    public function createMessage(Email $email)
    {
        /* @var $message \TYPO3\CMS\Core\Mail\MailMessage  */
        $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
        $message->setTo($email->getRecipientAddress())
                ->setFrom([
                    $this->senderEmail => $this->senderName,
                ])
                // Workaround for Yahoo mail
//                 ->setSubject($this->title);
                ->setSubject('=?UTF-8?B?'.base64_encode($this->title).'?=');

What do you think about that ?

Florian

IMHO the workaround is a bit messy, because the encoding is supposed to be done by the setSubject() method itself (or actually later in the process, but by SwiftMailer, never by Newsletter).

What TYPO3 do you have ? and more precisely what SwiftMailer version does it include ? you should find that either in typo3/cms/typo3/contrib/swiftmailer/VERSION or vendor/swiftmailer/swiftmailer/VERSION.

It seems your bug might be fixed by swiftmailer/swiftmailer#655, from SwiftMailer 5.4.2+, so that means TYPO3 8.2+.

My Typo3 version is 6.2.29 and the version of Swiftmailer is Swift-5.0.3.
But I agree with you I think that the problem could be in SwiftMailer.

I know my workaround is a bit messy but I had to find a solution for my customer and in any case, modifying an extension is not a good thing to do.

I already tried this fix swiftmailer/swiftmailer#655 but that's doesn't work.

Closing assuming newest SwiftMailer versions fixed this.