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

removed unused code inherited from version 4.0 #73

Merged
merged 7 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
49 changes: 9 additions & 40 deletions config/mail.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

declare(strict_types=1);

use Symfony\Component\Mailer\Transport\SendmailTransport;
arhimede marked this conversation as resolved.
Show resolved Hide resolved

return [

arhimede marked this conversation as resolved.
Show resolved Hide resolved
/**
* Dotkernel mail module configuration
* 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
* 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
alexmerlin marked this conversation as resolved.
Show resolved Hide resolved
*/

'dot_mail' => [
//the key is the mail service name, this is the default one, which does not extends any configuration
alexmerlin marked this conversation as resolved.
Show resolved Hide resolved
'default' => [
//tells which other mail service configuration to extend
'extends' => null,
alexmerlin marked this conversation as resolved.
Show resolved Hide resolved

/**
* the mail transport to use
* can be any class implementing Symfony\Component\Mailer\Transport\TransportInterface
Expand All @@ -26,88 +26,57 @@ return [
*
* defaults to sendmail
**/

'transport' => Symfony\Component\Mailer\Transport\SendmailTransport::class,

'transport' => SendmailTransport::class,
alexmerlin marked this conversation as resolved.
Show resolved Hide resolved
//message configuration
'message_options' => [

//from email address of the email
'from' => '',

//from name to be displayed instead of from address
'from_name' => '',

//reply-to email address of the email
'reply_to' => '',

//replyTo name to be displayed instead of the address
'reply_to_name' => '',

//destination email address as string or a list of email addresses
'to' => [],

//copy destination addresses
'cc' => [],

//hidden copy destination addresses
'bcc' => [],

//email subject
'subject' => '',

//body options - content can be plain text, HTML
'body' => [
'content' => '',
'charset' => 'utf-8',
],

//attachments config
'attachments' => [
'files' => [],
'dir' => [
'iterate' => false,
'path' => 'data/mail/attachments',
'recursive' => false,
]
],
],
],

//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
'host' => '',

//port of the mail server - 587 or 465 for secure connections
'port' => 587,

//connection class used for authentication
//the value can be one of smtp, plain, login or crammd5
'connection_class' => 'login',

'port' => 587,
'connection_config' => [

//the smtp authentication identity
'username' => '',

//the smtp authentication credential
'password' => '',

//the encryption type to be used, ssl or tls
//null should be used to disable SSL
'ssl' => 'tls',
]
],
],
],
// option to log the SENT emails
'log' => [
'sent' => getcwd() . '/log/mail/sent.log'
'sent' => getcwd() . '/log/mail/sent.log',
],

/**
* You can define other mail services here, with the same structure as the default block
* you can even extend from the default block, and overwrite only the differences
*/
],
];
11 changes: 0 additions & 11 deletions src/Options/MailOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
class MailOptions extends AbstractOptions
{
protected array $eventListeners = [];
protected array $saveSentMessageFolder = [];
protected TransportInterface|string $transport = SmtpTransport::class;
protected array $transportMap = [
'smtp' => [SmtpTransport::class],
Expand Down Expand Up @@ -89,14 +88,4 @@ public function setEventListeners(array $eventListeners): void
{
$this->eventListeners = $eventListeners;
}

public function getSaveSentMessageFolder(): array
{
return $this->saveSentMessageFolder;
}

public function setSaveSentMessageFolder(array $saveSentMessageFolder): void
{
$this->saveSentMessageFolder = $saveSentMessageFolder;
}
}
18 changes: 0 additions & 18 deletions src/Options/SmtpOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
class SmtpOptions extends AbstractOptions
{
protected string $name = 'localhost';
protected string $connectionClass = 'smtp';
protected array $connectionConfig = [];
protected string $host = '127.0.0.1';
protected int $port = 25;
Expand All @@ -36,23 +35,6 @@ public function setName(string $name): static
return $this;
}

/**
* Get connection class
*/
public function getConnectionClass(): string
{
return $this->connectionClass;
}

/**
* Set connection class
*/
public function setConnectionClass(string $connectionClass): static
{
$this->connectionClass = $connectionClass;
return $this;
}

/**
* Get connection configuration array
*/
Expand Down
17 changes: 2 additions & 15 deletions test/CommonTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ private function generateConfig(): array
*
* defaults to sendmail
**/
'transport' => SmtpTransport::class,

// Valid only if the Transport is SMTP
'save_sent_message_folder' => ['INBOX.Sent'],
'message_options' => [
'transport' => SmtpTransport::class,
'message_options' => [
'from' => '',
'from_name' => '',
'reply_to' => '',
Expand All @@ -84,21 +81,16 @@ private function generateConfig(): array
],
],
],

//options that will be used only if Symfony\Component\Mailer\Transport\Smtp\SmtpTransport
// adapter is used
'smtp_options' => [
'host' => 'testHost',
'port' => 587,
'connection_class' => 'login',
'connection_config' => [

//the smtp authentication identity
'username' => 'test',

//the smtp authentication credential
'password' => 'testPassword',
'ssl' => 'tls',
],
],
],
Expand All @@ -108,11 +100,6 @@ private function generateConfig(): array
'log' => [
'sent' => $this->fileSystem->url() . '/log/mail/sent.log',
],

/**
* You can define other mail services here, with the same structure as the default block
* you can even extend from the default block, and overwrite only the differences
*/
],
];
}
Expand Down
13 changes: 5 additions & 8 deletions test/Options/MailOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,22 @@ public function testGettersAndSetters(): void
{
$subject = new MailOptions();

$transport = 'smtp';
$transportMap = ['test' => 'array'];
$messageOptions = ['from' => '', 'to' => []];
$smtpOptions = ['host' => '', 'port' => 587];
$eventListeners = [AbstractMailEventListener::class];
$saveSentMessageFolder = ['INBOX.Sent'];
$transport = 'smtp';
$transportMap = ['test' => 'array'];
$messageOptions = ['from' => '', 'to' => []];
$smtpOptions = ['host' => '', 'port' => 587];
$eventListeners = [AbstractMailEventListener::class];

$subject->setTransport($transport);
$subject->setTransportMap($transportMap);
$subject->setMessageOptions($messageOptions);
$subject->setSmtpOptions($smtpOptions);
$subject->setEventListeners($eventListeners);
$subject->setSaveSentMessageFolder($saveSentMessageFolder);

$this->assertSame(SmtpTransport::class, $subject->getTransport());
$this->assertSame($transportMap, $subject->getTransportMap());
$this->assertInstanceOf(MessageOptions::class, $subject->getMessageOptions());
$this->assertInstanceOf(SmtpOptions::class, $subject->getSmtpOptions());
$this->assertSame($eventListeners, $subject->getEventListeners());
$this->assertSame($saveSentMessageFolder, $subject->getSaveSentMessageFolder());
}
}
1 change: 0 additions & 1 deletion test/Options/SmtpOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function testSmtpGettersAndSetters(): void
$this->assertIsString($subject->getName());
$this->assertIsArray($subject->getConnectionConfig());
$this->assertIsString($subject->getHost());
$this->assertIsString($subject->getConnectionClass());
$this->assertIsInt($subject->getPort());
$this->assertIsInt($subject->getConnectionTimeLimit());

Expand Down
Loading