diff --git a/composer.json b/composer.json index a16f4b78..14179594 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "dotkernel/dot-dependency-injection": "^1.0.0", "dotkernel/dot-errorhandler": "^4.0.0", "dotkernel/dot-flashmessenger": "^3.4.2", - "dotkernel/dot-mail": "~3.4 || ^4.1.1", + "dotkernel/dot-mail": "^5.0.0", "dotkernel/dot-navigation": "^3.4.2", "dotkernel/dot-rbac-guard": "^3.4.3", "dotkernel/dot-response-header": "^3.2.3", diff --git a/config/autoload/mail.local.php.dist b/config/autoload/mail.local.php.dist index ffea479a..b3b25676 100644 --- a/config/autoload/mail.local.php.dist +++ b/config/autoload/mail.local.php.dist @@ -6,10 +6,10 @@ return [ /** * Dotkernel mail module configuration - * Note that many of these options can be set programmaticaly too, when sending mail messages - * actually that is what you'll usually do, these config provide just default and options that - * remain the same for all mails + * Note that many of these options can be set programmatically too, when sending mail messages + * actually that is what you'll usually do, these config provide just default and options that remain the same for all mails */ + 'dot_mail' => [ //the key is the mail service name, this is the default one, which does not extends any configuration 'default' => [ @@ -18,21 +18,16 @@ return [ /** * the mail transport to use - * can be any class implementing Laminas\Mail\Transport\TransportInterface + * can be any class implementing Symfony\Component\Mailer\Transport\TransportInterface * * for standard mail transports, you can use these aliases - * - sendmail => Laminas\Mail\Transport\Sendmail - * - smtp => Laminas\Mail\Transport\Smtp - * - file => Laminas\Mail\Transport\File - * - in_memory => Laminas\Mail\Transport\InMemory + * - sendmail => Symfony\Component\Mailer\Transport\SendmailTransport + * - smtp => Symfony\Component\Mailer\Transport\Smtp\SmtpTransport * * defaults to sendmail **/ - 'transport' => Laminas\Mail\Transport\Sendmail::class, - // Uncomment the below line if you want to save a copy of all sent emails to a certain IMAP folder - // Valid only if the Transport is SMTP - // 'save_sent_message_folder' => ['INBOX.Sent'], + 'transport' => Symfony\Component\Mailer\Transport\SendmailTransport::class, //message configuration 'message_options' => [ @@ -64,21 +59,23 @@ return [ //body options - content can be plain text, HTML 'body' => [ 'content' => '', + 'charset' => 'utf-8', ], //attachments config 'attachments' => [ 'files' => [], - 'dir' => [ - 'iterate' => false, - 'path' => 'data/mail/attachments', + + 'dir' => [ + 'iterate' => false, + 'path' => 'data/mail/attachments', 'recursive' => false, - ], + ] ], ], - //options that will be used only if Laminas\Mail\Transport\Smtp adapter is used + //options that will be used only if Symfony\Component\Mailer\Transport\Smtp\SmtpTransport adapter is used 'smtp_options' => [ //hostname or IP address of the mail server @@ -89,45 +86,25 @@ return [ //connection class used for authentication //the value can be one of smtp, plain, login or crammd5 - 'connection_class' => 'login', + 'connection_class' => 'login', + 'connection_config' => [ //the smtp authentication identity - 'username' => '', + //'username' => '', //the smtp authentication credential - 'password' => '', + //'password' => '', //the encryption type to be used, ssl or tls //null should be used to disable SSL - 'ssl' => 'ssl', - ], - ], - - //file options that will be used only if the adapter is Laminas\Mail\Transport\File - /*'file_options' => [ - - //this is the folder where the file is going to be saved - //default value is 'data/mail/output' - 'path' => 'data/mail/output', - - //a callable that will get the Laminas\Mail\Transport\File object as an argument - // and should return the filename - //if null is used, and empty callable will be used - //'callback' => null, - ],*/ - - //listeners to register with the mail service, for mail events - 'event_listeners' => [ - //[ - //'type' => 'service or class name', - //'priority' => 1 - //], + 'ssl' => 'tls', + ] ], ], // option to log the SENT emails 'log' => [ - 'sent' => getcwd() . '/log/mail/sent.log', + 'sent' => getcwd() . '/log/mail/sent.log' ], /** diff --git a/test/Unit/Contact/Service/MessageServiceTest.php b/test/Unit/Contact/Service/MessageServiceTest.php index fdc3ecb0..ebcd1119 100644 --- a/test/Unit/Contact/Service/MessageServiceTest.php +++ b/test/Unit/Contact/Service/MessageServiceTest.php @@ -4,6 +4,7 @@ namespace FrontendTest\Unit\Contact\Service; +use Dot\Mail\Email; use Dot\Mail\Exception\MailException; use Dot\Mail\Result\ResultInterface; use Dot\Mail\Service\MailServiceInterface; @@ -41,10 +42,12 @@ public function testProcessMessage(): void $mailService = $this->createMock(MailServiceInterface::class); $template = $this->createMock(TemplateRendererInterface::class); $result = $this->createMock(ResultInterface::class); + $mail = $this->createMock(Email::class); + $mail->expects($this->once())->method('addFrom')->willReturn($mail); $result->expects($this->once())->method('isValid')->willReturn(true); $mailService->expects($this->once())->method('send')->willReturn($result); - + $mailService->expects($this->any())->method('getMessage')->willReturn($mail); $service = new MessageService( $messageRepository, $mailService,