[ticket/17135] Introduce Symfony Mailer for emails backend

PHPBB3-17135
This commit is contained in:
rxu 2023-05-05 19:59:45 +07:00
parent 4d61c52a46
commit df5ab5b5d8
No known key found for this signature in database
GPG key ID: 955F0567380E586A
4 changed files with 432 additions and 1297 deletions

File diff suppressed because it is too large Load diff

View file

@ -250,16 +250,16 @@ class message
$messenger->to($recipient['address'], $recipient['name']);
$messenger->im($recipient['jabber'], $recipient['username']);
$messenger->headers('X-AntiAbuse: Board servername - ' . $this->server_name);
$messenger->headers('X-AntiAbuse: User IP - ' . $this->sender_ip);
$messenger->headers('X-AntiAbuse', 'Board servername - ' . $this->server_name);
$messenger->headers('X-AntiAbuse', 'User IP - ' . $this->sender_ip);
if ($this->sender_id)
{
$messenger->headers('X-AntiAbuse: User_id - ' . $this->sender_id);
$messenger->headers('X-AntiAbuse', 'User_id - ' . $this->sender_id);
}
if ($this->sender_username)
{
$messenger->headers('X-AntiAbuse: Username - ' . $this->sender_username);
$messenger->headers('X-AntiAbuse', 'Username - ' . $this->sender_username);
}
$messenger->subject(html_entity_decode($this->subject, ENT_COMPAT));

View file

@ -70,6 +70,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$phpbb_container->set('assets.bag', $assets_bag);
$context = new \phpbb\template\context();
$dispatcher = new \phpbb\event\dispatcher();
$twig = new \phpbb\template\twig\environment(
$assets_bag,
$config,
@ -78,7 +79,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$cache_path,
null,
new \phpbb\template\twig\loader(''),
new \phpbb\event\dispatcher(),
$dispatcher,
array(
'cache' => false,
'debug' => false,
@ -95,6 +96,16 @@ class phpbb_email_parsing_test extends phpbb_test_case
$twig->addExtension($twig_extension);
$phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$phpbb_container->set('dispatcher', $dispatcher);
$phpbb_container->set('language', $lang);
$phpbb_container->set('request', $request);
$db = $this->getMockBuilder('\phpbb\db\driver\mysqli')
->disableOriginalConstructor()
->getMock();
$auth = $this->createMock('\phpbb\auth\auth');
$log = new \phpbb\log\log($db, $user, $auth, $dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
$phpbb_container->set('log', $log);
if (!class_exists('messenger'))
{

View file

@ -1,48 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
class phpbb_headers_encoding_test extends phpbb_test_case
{
protected function setUp(): void
{
global $phpbb_root_path, $phpEx;
if (!function_exists('mail_encode'))
{
include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
}
}
public function headers_encoding_data()
{
return [
['test@yourdomain.com <phpBB fake test email>', 'Q', 'US-ASCII'],
['test@yourdomain.com <Несуществующий почтовый адрес phpBB>', 'B', 'UTF-8'],
["\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88", 'B', 'UTF-8'],
];
}
/**
* @dataProvider headers_encoding_data
*/
public function test_headers_encoding($header, $scheme, $encoding)
{
$encoded_string = mail_encode($header);
$this->assertStringStartsWith("=?$encoding?$scheme?", $encoded_string);
$this->assertStringEndsWith('?=', $encoded_string);
// Result of iconv_mime_decode() on decoded header should be equal to initial header
$decoded_string = iconv_mime_decode($encoded_string, 0, $encoding);
$this->assertEquals(0, strcmp($header, $decoded_string));
}
}