more mail bug fixes

This commit is contained in:
Dennis Eichhorn 2020-12-23 20:57:23 +01:00
parent 8fdf9f96e7
commit a5a9d20941
4 changed files with 20 additions and 4 deletions

View File

@ -692,7 +692,7 @@ class Email implements MessageInterface
: $this->messageDate->format('D, j M Y H:i:s O'))
. self::$LE;
if ($this->mailer === SubmitType::MAIL) {
if ($this->mailer !== SubmitType::MAIL) {
$result .= \count($this->to) > 0
? $this->addrAppend('To', $this->to)
: 'To: undisclosed-recipients:;' . self::$LE;
@ -706,7 +706,9 @@ class Email implements MessageInterface
}
// sendmail and mail() extract Bcc from the header before sending
if (($this->mailer === SubmitType::MAIL || $this->mailer === SubmitType::SENDMAIL || $this->mailer === SubmitType::QMAIL)
if (($this->mailer === SubmitType::MAIL
|| $this->mailer === SubmitType::SENDMAIL
|| $this->mailer === SubmitType::QMAIL)
&& \count($this->bcc) > 0
) {
$result .= $this->addrAppend('Bcc', $this->bcc);

View File

@ -437,7 +437,7 @@ final class ArrayUtils
$diff = [];
foreach ($values1 as $key => $value) {
if (\is_array($value)) {
if (!array_key_exists($key, $values2) || !\is_array($values2[$key])) {
if (!\array_key_exists($key, $values2) || !\is_array($values2[$key])) {
$diff[$key] = $value;
} else {
$subDiff = self::array_diff_assoc_recursive($value, $values2[$key]);

View File

@ -42,6 +42,20 @@ class MailHandlerTest extends \PHPUnit\Framework\TestCase
self::assertTrue($mailer->send($mail));
}
public function testSendTextWithSendmail() : void
{
$mailer = new MailHandler();
$mailer->setMailer(SubmitType::SENDMAIL);
$mail = new Email();
$mail->setFrom('dennis.eichhorn@orange-management.org', 'Dennis Eichhorn');
$mail->addTo('info@orange-management.org', 'Dennis Eichhorn');
$mail->subject = 'Test email';
$mail->body = 'This is some content';
self::assertTrue($mailer->send($mail));
}
public function testReceiveMailWithImap() : void
{/*
$mailer = new Imap();

View File

@ -398,7 +398,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
{
$dirTestPath = __DIR__ . '/dirtest';
self::assertCount(6, Directory::list($dirTestPath, '*', true));
self::assertEquals(['sub/test2.txt', 'sub/test4.md', 'sub/path/test3.txt'], Directory::list($dirTestPath, 'test[0-9]+.*', true));
self::assertEquals([], \array_diff(['sub/test2.txt', 'sub/test4.md', 'sub/path/test3.txt'], Directory::list($dirTestPath, 'test[0-9]+.*', true)));
self::assertCount(2, Directory::list($dirTestPath, '*', false));
}