mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Fixes #5498 CC emails are now added correctly. DKIM identity corrected. Core prefs are no longer stored in the instance.
This commit is contained in:
@@ -168,7 +168,7 @@ class e107Email extends PHPMailer
|
|||||||
|
|
||||||
public $legacyBody = false; // true enables legacy conversion of plain text body to HTML in HTML emails
|
public $legacyBody = false; // true enables legacy conversion of plain text body to HTML in HTML emails
|
||||||
private $debug = false; // echos various debug info when set to true.
|
private $debug = false; // echos various debug info when set to true.
|
||||||
private $pref = array(); // Store code prefs.
|
|
||||||
private $previewMode = false;
|
private $previewMode = false;
|
||||||
private $previewAttachments = array();
|
private $previewAttachments = array();
|
||||||
private $overrides = array(
|
private $overrides = array(
|
||||||
@@ -218,7 +218,6 @@ class e107Email extends PHPMailer
|
|||||||
$this->Debugoutput = 'handlePHPMailerDebug';
|
$this->Debugoutput = 'handlePHPMailerDebug';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pref = $pref;
|
|
||||||
|
|
||||||
$this->CharSet = 'utf-8';
|
$this->CharSet = 'utf-8';
|
||||||
$this->setLanguage(CORE_LC);
|
$this->setLanguage(CORE_LC);
|
||||||
@@ -356,7 +355,7 @@ class e107Email extends PHPMailer
|
|||||||
$this->DKIM_private = $privatekeyfile;
|
$this->DKIM_private = $privatekeyfile;
|
||||||
$this->DKIM_selector = 'phpmailer';
|
$this->DKIM_selector = 'phpmailer';
|
||||||
$this->DKIM_passphrase = ''; //key is not encrypted
|
$this->DKIM_passphrase = ''; //key is not encrypted
|
||||||
$this->DKIM_identifier = $this->From;
|
$this->DKIM_identity = $this->From;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -515,6 +514,7 @@ class e107Email extends PHPMailer
|
|||||||
*/
|
*/
|
||||||
public function AddAddressList($list = 'to', $addresses = '', $names = '')
|
public function AddAddressList($list = 'to', $addresses = '', $names = '')
|
||||||
{
|
{
|
||||||
|
|
||||||
$list = trim(strtolower($list));
|
$list = trim(strtolower($list));
|
||||||
$tmp = explode(',', $addresses);
|
$tmp = explode(',', $addresses);
|
||||||
|
|
||||||
@@ -526,9 +526,11 @@ class e107Email extends PHPMailer
|
|||||||
{
|
{
|
||||||
$names = explode(',', $names);
|
$names = explode(',', $names);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($tmp as $k => $adr)
|
foreach($tmp as $k => $adr)
|
||||||
{
|
{
|
||||||
$to_name = ($names[$k]) ? $names[$k] : $adr;
|
$to_name = ($names[$k]) ? $names[$k] : $adr;
|
||||||
|
|
||||||
switch($list)
|
switch($list)
|
||||||
{
|
{
|
||||||
case 'to' :
|
case 'to' :
|
||||||
@@ -542,6 +544,7 @@ class e107Email extends PHPMailer
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'replyto' :
|
case 'replyto' :
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -553,13 +556,9 @@ class e107Email extends PHPMailer
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cc' :
|
case 'cc' :
|
||||||
if($this->Mailer == 'mail')
|
|
||||||
{
|
|
||||||
$this->addCustomHeader('Cc: '.$adr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->addCC($adr, $to_name);
|
$this->addCC($adr, $to_name);
|
||||||
@@ -569,15 +568,10 @@ class e107Email extends PHPMailer
|
|||||||
$this->logLine($e->getMessage());
|
$this->logLine($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'bcc' :
|
case 'bcc' :
|
||||||
if($this->Mailer == 'mail')
|
|
||||||
{
|
|
||||||
$this->addCustomHeader('Bcc: '.$adr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->addBCC($adr, $to_name);
|
$this->addBCC($adr, $to_name);
|
||||||
@@ -587,12 +581,13 @@ class e107Email extends PHPMailer
|
|||||||
$this->logLine($e->getMessage());
|
$this->logLine($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -842,9 +837,12 @@ class e107Email extends PHPMailer
|
|||||||
$eml['shortcodes']['BODY'] = !empty($eml['body']) ? $tp->toEmail($eml['body']) : '';
|
$eml['shortcodes']['BODY'] = !empty($eml['body']) ? $tp->toEmail($eml['body']) : '';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$siteTheme = e107::getConfig()->get('site_theme');
|
||||||
|
|
||||||
$eml['shortcodes']['BODY'] = !empty($eml['body']) ? $eml['body'] : ''; // $tp->toEmail($eml['body']) : '';
|
$eml['shortcodes']['BODY'] = !empty($eml['body']) ? $eml['body'] : ''; // $tp->toEmail($eml['body']) : '';
|
||||||
$eml['shortcodes']['SUBJECT'] = !empty($eml['subject']) ? $eml['subject'] : '';
|
$eml['shortcodes']['SUBJECT'] = !empty($eml['subject']) ? $eml['subject'] : '';
|
||||||
$eml['shortcodes']['THEME'] = ($this->previewMode == true) ? e_THEME_ABS.$this->pref['sitetheme'].'/' : e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
|
$eml['shortcodes']['THEME'] = ($this->previewMode) ? e_THEME_ABS.$siteTheme.'/' : e_THEME.$siteTheme.'/'; // Always use front-end theme path.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
$this->fail("Couldn't load e107Email object");
|
$this::fail("Couldn't load e107Email object");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -60,12 +60,39 @@
|
|||||||
|
|
||||||
$this->eml->arraySet($eml);
|
$this->eml->arraySet($eml);
|
||||||
|
|
||||||
$this->assertStringContainsString("noreply@test.com", $this->eml->From);
|
$this::assertStringContainsString("noreply@test.com", $this->eml->From);
|
||||||
$this->assertStringContainsString("Test Person", $this->eml->FromName);
|
$this::assertStringContainsString("Test Person", $this->eml->FromName);
|
||||||
$this->assertStringContainsString("e107: [URGENT EXAMPLE] ", $this->eml->Subject);
|
$this::assertStringContainsString("e107: [URGENT EXAMPLE] ", $this->eml->Subject);
|
||||||
$this->assertStringContainsString("This is the body text", $this->eml->Body);
|
$this::assertStringContainsString("This is the body text", $this->eml->Body);
|
||||||
$this->assertStringContainsString("<h4 class='sitename'><a href='", $this->eml->Body);
|
$this::assertStringContainsString("<h4 class='sitename'><a href='", $this->eml->Body);
|
||||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
$this::assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testArraySetCC()
|
||||||
|
{
|
||||||
|
$eml = array(
|
||||||
|
'subject' => "[CC EXAMPLE]",
|
||||||
|
'sender_email' => "noreply@test.com",
|
||||||
|
'sender_name' => "Test Person",
|
||||||
|
'replyto' => "",
|
||||||
|
'html' => true,
|
||||||
|
'priority' => 1,
|
||||||
|
'template' => 'default',
|
||||||
|
'body' => "This is the body text",
|
||||||
|
'cc' => 'email1@example.com,email2@example.com,email3@example.com'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->eml->Mailer = 'mail';
|
||||||
|
|
||||||
|
$this->eml->arraySet($eml);
|
||||||
|
$result = $this->eml->getCcAddresses();
|
||||||
|
|
||||||
|
$this::assertIsArray($result);
|
||||||
|
$this::assertNotEmpty($result, 'CC Array is empty' );;
|
||||||
|
$this::assertEquals('email1@example.com', $result[0][0]);
|
||||||
|
$this::assertEquals('email2@example.com', $result[1][0]);
|
||||||
|
$this::assertEquals('email3@example.com', $result[2][0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,14 +119,14 @@
|
|||||||
|
|
||||||
$this->eml->arraySet($eml);
|
$this->eml->arraySet($eml);
|
||||||
|
|
||||||
$this->assertStringContainsString("noreply@test.com", $this->eml->From);
|
$this::assertStringContainsString("noreply@test.com", $this->eml->From);
|
||||||
$this->assertStringContainsString("Test Person", $this->eml->FromName);
|
$this::assertStringContainsString("Test Person", $this->eml->FromName);
|
||||||
$this->assertStringContainsString("[CUSTOM TEMPLATE EXAMPLE]", $this->eml->Subject);
|
$this::assertStringContainsString("[CUSTOM TEMPLATE EXAMPLE]", $this->eml->Subject);
|
||||||
|
|
||||||
$this->assertStringContainsString('<html lang="en"><body>', $this->eml->Body);
|
$this::assertStringContainsString('<html lang="en"><body>', $this->eml->Body);
|
||||||
|
|
||||||
$this->assertStringContainsString('<div><span>TestName</span> <small>Jan 1st, 2020</small></div><div>This is the body text</div>', $this->eml->Body);
|
$this::assertStringContainsString('<div><span>TestName</span> <small>Jan 1st, 2020</small></div><div>This is the body text</div>', $this->eml->Body);
|
||||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
$this::assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -127,14 +154,14 @@
|
|||||||
|
|
||||||
$this->eml->arraySet($eml);
|
$this->eml->arraySet($eml);
|
||||||
|
|
||||||
$this->assertStringContainsString("noreply@test.com", $this->eml->From);
|
$this::assertStringContainsString("noreply@test.com", $this->eml->From);
|
||||||
$this->assertStringContainsString("Test Person", $this->eml->FromName);
|
$this::assertStringContainsString("Test Person", $this->eml->FromName);
|
||||||
$this->assertStringContainsString("[PLUGIN TEMPLATE EXAMPLE]", $this->eml->Subject);
|
$this::assertStringContainsString("[PLUGIN TEMPLATE EXAMPLE]", $this->eml->Subject);
|
||||||
|
|
||||||
$this->assertStringContainsString('<html lang="en"><body>', $this->eml->Body);
|
$this::assertStringContainsString('<html lang="en"><body>', $this->eml->Body);
|
||||||
|
|
||||||
$this->assertStringContainsString('<div><span>TestName</span> <small>Jan 1st, 2020</small></div><div>This is the body text</div>', $this->eml->Body);
|
$this::assertStringContainsString('<div><span>TestName</span> <small>Jan 1st, 2020</small></div><div>This is the body text</div>', $this->eml->Body);
|
||||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
$this::assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,12 +183,12 @@
|
|||||||
|
|
||||||
$this->eml->arraySet($eml);
|
$this->eml->arraySet($eml);
|
||||||
|
|
||||||
$this->assertStringContainsString("noreply@test.com", $this->eml->From);
|
$this::assertStringContainsString("noreply@test.com", $this->eml->From);
|
||||||
$this->assertStringContainsString("Test Person", $this->eml->FromName);
|
$this::assertStringContainsString("Test Person", $this->eml->FromName);
|
||||||
$this->assertStringContainsString("e107: [URGENT EXAMPLE] ", $this->eml->Subject);
|
$this::assertStringContainsString("e107: [URGENT EXAMPLE] ", $this->eml->Subject);
|
||||||
$this->assertStringContainsString("This is the body text", $this->eml->Body);
|
$this::assertStringContainsString("This is the body text", $this->eml->Body);
|
||||||
$this->assertStringContainsString("<div class='unsubscribe'></div>", $this->eml->Body);
|
$this::assertStringContainsString("<div class='unsubscribe'></div>", $this->eml->Body);
|
||||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
$this::assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public function testMakePrintableAddress()
|
public function testMakePrintableAddress()
|
||||||
@@ -198,7 +225,7 @@ Admin<br />
|
|||||||
|
|
||||||
$result = json_encode($this->eml->AltBody);
|
$result = json_encode($this->eml->AltBody);
|
||||||
$expected = '"Hi Joe\r\nCheck out https:\/\/e107.org\r\n\r\nThanks,\r\nAdmin\r\n\r\nWebsite:\thttps:\/\/e107.org\t\r\nGithub:\thttps:\/\/github.com\/e107inc\/"';
|
$expected = '"Hi Joe\r\nCheck out https:\/\/e107.org\r\n\r\nThanks,\r\nAdmin\r\n\r\nWebsite:\thttps:\/\/e107.org\t\r\nGithub:\thttps:\/\/github.com\/e107inc\/"';
|
||||||
$this->assertSame($expected, $result);
|
$this::assertSame($expected, $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -268,11 +295,11 @@ Admin<br />
|
|||||||
|
|
||||||
$result = $this->eml->getSentMIMEMessage();
|
$result = $this->eml->getSentMIMEMessage();
|
||||||
|
|
||||||
$this->assertStringContainsString('Content-Type: text/plain;', $result);
|
$this::assertStringContainsString('Content-Type: text/plain;', $result);
|
||||||
$this->assertStringContainsString('This is the body text', $result);
|
$this::assertStringContainsString('This is the body text', $result);
|
||||||
|
|
||||||
$this->assertStringContainsString('Content-Type: text/html;', $result);
|
$this::assertStringContainsString('Content-Type: text/html;', $result);
|
||||||
$this->assertStringContainsString('Hi,<br />This is the <b>body</b> text', $result);
|
$this::assertStringContainsString('Hi,<br />This is the <b>body</b> text', $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,8 +314,8 @@ Admin<br />
|
|||||||
$randomString1 = uniqid();
|
$randomString1 = uniqid();
|
||||||
$randomString2 = uniqid();
|
$randomString2 = uniqid();
|
||||||
|
|
||||||
$this->assertFalse($this->fileContainsString($logFilePath, $randomString1));
|
$this::assertFalse($this->fileContainsString($logFilePath, $randomString1));
|
||||||
$this->assertFalse($this->fileContainsString($logFilePath, $randomString2));
|
$this::assertFalse($this->fileContainsString($logFilePath, $randomString2));
|
||||||
|
|
||||||
$eml = $this->make('e107Email', ['send' => function() { return true; }]);
|
$eml = $this->make('e107Email', ['send' => function() { return true; }]);
|
||||||
$eml->logEnable(2);
|
$eml->logEnable(2);
|
||||||
@@ -297,13 +324,13 @@ Admin<br />
|
|||||||
"$randomString1 Example",
|
"$randomString1 Example",
|
||||||
['body' => 'Message body'],
|
['body' => 'Message body'],
|
||||||
);
|
);
|
||||||
$this->assertTrue($this->fileContainsString($logFilePath, $randomString1));
|
$this::assertTrue($this->fileContainsString($logFilePath, $randomString1));
|
||||||
$eml->sendEmail(
|
$eml->sendEmail(
|
||||||
'nobody2@example.com',
|
'nobody2@example.com',
|
||||||
"$randomString2 Example",
|
"$randomString2 Example",
|
||||||
['body' => 'Message body'],
|
['body' => 'Message body'],
|
||||||
);
|
);
|
||||||
$this->assertTrue($this->fileContainsString($logFilePath, $randomString2));
|
$this::assertTrue($this->fileContainsString($logFilePath, $randomString2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user