Merge branch 'fix-email-encoding-issues' into 'develop'

Fix email issues

Closes #419 et #416

See merge request framasoft/framadate/framadate!364
This commit is contained in:
Thomas Citharel 2019-04-16 11:37:21 +02:00
commit 69d00042e6
2 changed files with 22 additions and 7 deletions

View File

@ -68,10 +68,12 @@ class MailService {
// Bodies
$body = $body . ' <br/><br/>' . __('Mail', 'Thank you for your trust.') . ' <br/>' . NOMAPPLICATION . ' <hr/>' . __('Mail', "\"The road is long, but the way is clear…\"<br/>Framasoft lives only by your donations.<br/>Thank you in advance for your support https://soutenir.framasoft.org");
$mail->isHTML(true);
$mail->msgHTML($body, ROOT_DIR, true);
$mail->CharSet = PHPMailer::CHARSET_UTF8;
$mail->msgHTML($body, ROOT_DIR, function ($html) use ($mail) {
return $this->html2text($mail, $html);
});
// Build headers
$mail->CharSet = 'UTF-8';
$mail->addCustomHeader('Auto-Submitted', 'auto-generated');
$mail->addCustomHeader('Return-Path', '<>');
@ -124,4 +126,16 @@ class MailService {
}
}
}
/**
* Custom "advanced" callback to pass to msgHTML function
*
* @param PHPMailer $mailer a PHPMailer instance
* @param string $html the HTML body of an email
*/
private function html2text(PHPMailer $mailer, $html) {
$html = preg_replace('/<a[^>]*href="([^"]+)"[^>]*>(.*?)<\/a>/si', '${2}: ${1}', $html);
return $mailer->html2text($html);
}
}

11
composer.lock generated
View File

@ -806,16 +806,16 @@
},
{
"name": "phpmailer/phpmailer",
"version": "v6.0.5",
"version": "v6.0.7",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "cb3ea134d4d3729e7857737d5f320cce9caf4d32"
"reference": "0c41a36d4508d470e376498c1c0c527aa36a2d59"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/cb3ea134d4d3729e7857737d5f320cce9caf4d32",
"reference": "cb3ea134d4d3729e7857737d5f320cce9caf4d32",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/0c41a36d4508d470e376498c1c0c527aa36a2d59",
"reference": "0c41a36d4508d470e376498c1c0c527aa36a2d59",
"shasum": ""
},
"require": {
@ -868,7 +868,7 @@
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"time": "2018-03-27T13:49:45+00:00"
"time": "2019-02-01T15:04:28+00:00"
},
{
"name": "psr/log",
@ -2580,6 +2580,7 @@
"mock",
"xunit"
],
"abandoned": true,
"time": "2017-06-30T09:13:00+00:00"
},
{