Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated dotkernel/dot-mail package #518

Merged
merged 5 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
65 changes: 21 additions & 44 deletions config/autoload/mail.local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand All @@ -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' => [
Expand Down Expand Up @@ -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
Expand All @@ -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'
],

/**
Expand Down
5 changes: 4 additions & 1 deletion test/Unit/Contact/Service/MessageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down