8000 Add SES Session Token again to Symfony Mailer by Jubeki · Pull Request #38794 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Add SES Session Token again to Symfony Mailer #38794

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

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
22987f2
Adds policy option to make:model
tfevens Sep 8, 2021
22defeb
Style guide fixes
tfevens Sep 8, 2021
46d7093
Include --model to make:policy
tfevens Sep 10, 2021
27bcf13
return on null
taylorotwell Sep 10, 2021
363ad00
formatting
taylorotwell Sep 10, 2021
240bf68
Merge branch 'tfevens/8.x' into 8.x
taylorotwell Sep 10, 2021
50eca08
Cache: Provide psr/simple-cache-implementation (#38767)
Xenonym Sep 12, 2021
510651a
Use lowercase for hmac hash algorithm (#38787)
Krisell Sep 13, 2021
c42c356
allow tests to utilise the null logger (#38785)
timacdonald Sep 13, 2021
a228123
Add `deleteOrFail` to `Model` (#38784)
caugner Sep 13, 2021
11edec3
Fix tests
driesvints Sep 13, 2021
b4e3823
Bump DBAL
driesvints Sep 13, 2021
59ff96c
[8.x] Add `assertExists` testing method (#38766)
RVxLab Sep 13, 2021
8000
cb56b3a
Revert "Fix tests"
driesvints Sep 13, 2021
bd3c4bb
Revert "Bump DBAL"
driesvints Sep 13, 2021
7d3151c
Disable test for now
driesvints Sep 13, 2021
3234a8d
Merge branch '8.x'
driesvints Sep 13, 2021
bcc81b8
Implement Symfony Mailer
driesvints Aug 20, 2021
1aad29a
Apply fixes from StyleCI
taylorotwell Aug 20, 2021
46f6564
Update src/Illuminate/Mail/Message.php
driesvints Aug 21, 2021
97b3dd7
Update src/Illuminate/Mail/Message.php
driesvints Aug 21, 2021
9a941fe
Update src/Illuminate/Mail/Message.php
driesvints Aug 21, 2021
508bc4e
Update src/Illuminate/Mail/Message.php
driesvints Aug 21, 2021
e9ae7da
Update src/Illuminate/Mail/Message.php
driesvints Aug 21, 2021
0ccecbe
Update Array and Log transports
driesvints Aug 23, 2021
de351bb
Apply fixes from StyleCI
taylorotwell Aug 23, 2021
d9b0b86
Fix interface implementation
driesvints Aug 23, 2021
e5d5987
Update Mailer
driesvints Aug 23, 2021
672ada6
Apply fixes from StyleCI
taylorotwell Aug 23, 2021
73cf0e6
Rename
driesvints Aug 23, 2021
a10eabe
Remove method
driesvints Aug 23, 2021
7d09674
Fix tests
driesvints Aug 23, 2021
4ad0098
Apply fixes from StyleCI
taylorotwell Aug 23, 2021
becc5ba
Work on Mailer tests
driesvints Aug 24, 2021
d861c9e
type-hint
driesvints Aug 24, 2021
3dab55a
Fix Mailer tests
driesvints Aug 25, 2021
6bbb476
Fix more tests
driesvints Aug 25, 2021
53969a4
Apply fixes from StyleCI
taylorotwell Aug 25, 2021
3e78769
Migrate Mailgun transport
driesvints Aug 27, 2021
dcdf58f
Migrate Postmark transport
driesvints Aug 27, 2021
c427ece
Replace SesTransport
driesvints Aug 30, 2021
a0253c8
Remove transports from dev dependencies
driesvints Aug 30, 2021
141caa9
Allow setting options on esmtp transport
driesvints Sep 2, 2021
b1ddbe5
Fix Postmark transport
driesvints Sep 3, 2021
d1c244a
Fix embedding files
driesvints Sep 3, 2021
f6e9fe7
Clarify API transports
driesvints Sep 3, 2021
493284c
Apply fixes from StyleCI
taylorotwell Sep 7, 2021
1bf1242
Fix SES transport setup
driesvints Sep 8, 2021
491cc37
Add MessageStreamId to Postmark Transport again (#38748)
Jubeki Sep 10, 2021
4938b1c
Update symfony mailer docblocks (#38773)
Jubeki Sep 12, 2021
f942a52
Add Session Token to SES Transport
Jubeki Sep 13, 2021
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
Prev Previous commit
Next Next commit
Update Mailer
  • Loading branch information
driesvints authored and Jubeki committed Sep 13, 2021
commit e5d598715c583e04b5693dcca6e4a44bdbc165da
7 changes: 0 additions & 7 deletions src/Illuminate/Contracts/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,4 @@ public function raw($text, $callback);
* @return void
*/
public function send($view, array $data = [], $callback = null);

/**
* Get the array of failed recipients.
*
* @return array
*/
public function failures();
}
13 changes: 1 addition & 12 deletions src/Illuminate/Mail/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function resolve($name)
$mailer = new Mailer(
$name,
$this->app['view'],
$this->createSymfonyMailer($config),
$this->createTransport($config),
$this->app['events']
);

Expand All @@ -134,17 +134,6 @@ protected function resolve($name)
return $mailer;
}

/**
* Create the Symfony Mailer instance for the given configuration.
*
* @param array $config
* @return \Symfony\Component\Mailer\MailerInterface
*/
protected function createSymfonyMailer(array $config)
{
return new SymfonyMailer($this->createTransport($config));
}

/**
* Create a new transport instance.
*
Expand Down
79 changes: 28 additions & 51 deletions src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Illuminate\Support\HtmlString;
use Illuminate\Support\Traits\Macroable;
use InvalidArgumentException;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mailer\Transport\TransportInterface;
use Symfony\Component\Mime\Email;

class Mailer implements MailerContract, MailQueueContract
Expand All @@ -37,11 +37,11 @@ class Mailer implements MailerContract, MailQueueContract
protected $views;

/**
* The Symfony Mailer instance.
* The Symfony Transport instance.
*
* @var \Symfony\Component\Mailer\MailerInterface
* @var \Symfony\Component\Mailer\Transport\TransportInterface
*/
protected $mailer;
protected $transport;

/**
* The event dispatcher instance.
Expand Down Expand Up @@ -85,28 +85,21 @@ class Mailer implements MailerContract, MailQueueContract
*/
protected $queue;

/**
* Array of failed recipients.
*
* @var array
*/
protected $failedRecipients = [];

/**
* Create a new Mailer instance.
*
* @param string $name
* @param \Illuminate\Contracts\View\Factory $views
* @param \Symfony\Component\Mailer\MailerInterface $mailer
* @param \Symfony\Component\Mailer\Transport\TransportInterface $transport
* @param \Illuminate\Contracts\Events\Dispatcher|null $events
* @return void
*/
public function __construct(string $name, Factory $views, MailerInterface $mailer, Dispatcher $events = null)
public function __construct(string $name, Factory $views, TransportInterface $transport, Dispatcher $events = null)
{
$this->name = $name;
$this->views = $views;
$this->mailer = $mailer;
$this->events = $events;
$this->transport = $transport;
}

/**
Expand Down Expand Up @@ -283,10 +276,10 @@ public function send($view, array $data = [], $callback = null)
// Next we will determine if the message should be sent. 8000 We give the developer
// one final chance to stop this message and then we will send it to all of
// its recipients. We will then fire the sent event for the sent message.
$swiftMessage = $message->getSwiftMessage();
$symfonyMessage = $message->getSymfonyMessage();

if ($this->shouldSendMessage($swiftMessage, $data)) {
$this->sendSwiftMessage($swiftMessage);
if ($this->shouldSendMessage($symfonyMessage, $data)) {
$this->sendSymfonyMessage($symfonyMessage);

$this->dispatchSentEvent($message, $data);
}
Expand Down Expand Up @@ -353,19 +346,15 @@ protected function parseView($view)
protected function addContent($message, $view, $plain, $raw, $data)
{
if (isset($view)) {
$message->setBody($this->renderView($view, $data) ?: ' ', 'text/html');
$message->html($this->renderView($view, $data) ?: ' ');
}

if (isset($plain)) {
$method = isset($view) ? 'addPart' : 'setBody';

$message->$method($this->renderView($plain, $data) ?: ' ', 'text/plain');
$message->text($this->renderView($plain, $data) ?: ' ');
}

if (isset($raw)) {
$method = (isset($view) || isset($plain)) ? 'addPart' : 'setBody';

$message->$method($raw, 'text/plain');
$message->text($raw);
}
}

Expand Down Expand Up @@ -509,26 +498,24 @@ protected function createMessage()
}

/**
* Send a Swift Message instance.
* Send a Symfony Email instance.
*
* @param \Swift_Message $message
* @param \Symfony\Component\Mime\Email $message
* @return int|null
*/
protected function sendSwiftMessage($message)
protected function sendSymfonyMessage(Email $message)
{
$this->failedRecipients = [];

try {
return $this->swift->send($message, $this->failedRecipients);
return $this->transport->send($message);
} finally {
$this->forceReconnection();
}
}

/**
* Determines if the message can be sent.
* Determines if the email can be sent.
*
* @param \Swift_Message $message
* @param \Symfony\Component\Mime\Email $message
* @param array $data
* @return bool
*/
Expand Down Expand Up @@ -568,27 +555,17 @@ protected function dispatchSentEvent($message, $data = [])
*/
protected function forceReconnection()
{
$this->getSwiftMailer()->getTransport()->stop();
}

/**
* Get the array of failed recipients.
*
* @return array
*/
public function failures()
{
return $this->failedRecipients;
$this->getSymfonyMailer()->getTransport()->stop();
}

/**
* Get the Symfony Mailer instance.
* Get the Symfony Transport instance.
*
* @return \Symfony\Component\Mailer\MailerInterface
* @return \Symfony\Component\Mailer\Transport\TransportInterface
*/
public function getSymfonyMailer()
public function getSymfonyTransport()
{
return $this->mailer;
return $this->transport;
}

/**
Expand All @@ -602,14 +579,14 @@ public function getViewFactory()
}

/**
* Set the Symfony Mailer instance.
* Set the Symfony Transport instance.
*
* @param \Symfony\Component\Mailer\MailerInterface $mailer
* @param \Symfony\Component\Mailer\Transport\TransportInterface $transport
* @return void
*/
public function setSymfonyMailer($mailer)
public function setSymfonyTransport($transport)
{
$this->mailer = $mailer;
$this->transport = $transport;
}

/**
Expand Down
48 changes: 24 additions & 24 deletions src/Illuminate/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Message
*
* @var \Symfony\Component\Mime\Email
*/
protected $email;
protected $message;

/**
* CIDs of files embedded in the message.
Expand All @@ -30,12 +30,12 @@ class Message
/**
* Create a new message instance.
*
* @param \Symfony\Component\Mime\Email $email
* @param \Symfony\Component\Mime\Email $message
* @return void
*/
public function __construct(Email $email)
public function __construct(Email $message)
{
$this->email = $email;
$this->message = $message;
}

/**
Expand All @@ -48,8 +48,8 @@ public function __construct(Email $email)
public function from($address, $name = null)
{
is_array($address)
? $this->email->from(...$address)
: $this->email->from(new Address($address, (string) $name));
? $this->message->from(...$address)
: $this->message->from(new Address($address, (string) $name));

return $this;
}
Expand All @@ -64,8 +64,8 @@ public function from($address, $name = null)
public function sender($address, $name = null)
{
is_array($address)
? $this->email->sender(...$address)
: $this->email->sender(new Address($address, (string) $name));
? $this->message->sender(...$address)
: $this->message->sender(new Address($address, (string) $name));

return $this;
}
Expand All @@ -78,7 +78,7 @@ public function sender($address, $name = null)
*/
public function returnPath($address)
{
$this->email->returnPath($address);
$this->message->returnPath($address);

return $this;
}
Expand All @@ -95,8 +95,8 @@ public function to($address, $name = null, $override = false)
{
if ($override) {
is_array($address)
? $this->email->to(...$address)
: $this->email->to(new Address($address, (string) $name));
? $this->message->to(...$address)
: $this->message->to(new Address($address, (string) $name));

return $this;
}
Expand All @@ -116,8 +116,8 @@ public function cc($address, $name = null, $override = false)
{
if ($override) {
is_array($address)
? $this->email->cc(...$address)
: $this->email->cc(new Address($address, (string) $name));
? $this->message->cc(...$address)
: $this->message->cc(new Address($address, (string) $name));

return $this;
}
Expand All @@ -137,8 +137,8 @@ public function bcc($address, $name = null, $override = false)
{
if ($override) {
is_array($address)
? $this->email->bcc(...$address)
: $this->email->bcc(new Address($address, (string) $name));
? $this->message->bcc(...$address)
: $this->message->bcc(new Address($address, (string) $name));

return $this;
}
Expand Down Expand Up @@ -179,9 +179,9 @@ protected function addAddresses($address, $name, $type)
return $address;
})->all();

$this->email->{"{$type}"}(...$addresses);
$this->message->{"{$type}"}(...$addresses);
} else {
$this->email->{"add{$type}"}(new Address($address, (string) $name));
$this->message->{"add{$type}"}(new Address($address, (string) $name));
}

return $this;
Expand All @@ -195,7 +195,7 @@ protected function addAddresses($address, $name, $type)
*/
public function subject($subject)
{
$this->email->subject($subject);
$this->message->subject($subject);

return $this;
}
Expand All @@ -208,7 +208,7 @@ public function subject($subject)
*/
public function priority($level)
{
$this->email->priority($level);
$this->message->priority($level);

return $this;
}
Expand All @@ -222,7 +222,7 @@ public function priority($level)
*/
public function attach($file, array $options = [])
{
$this->email->attachFromPath($file, $options['as'] ?? null, $options['mime'] ?? null);
$this->message->attachFromPath($file, $options['as'] ?? null, $options['mime'] ?? null);

return $this;
}
Expand All @@ -237,7 +237,7 @@ public function attach($file, array $options = [])
*/
public function attachData($data, $name, array $options = [])
{
$this->email->attach($data, $name, $options['mime'] ?? null);
$this->message->attach($data, $name, $options['mime'] ?? null);

return $this;
}
Expand All @@ -250,7 +250,7 @@ public function attachData($data, $name, array $options = [])
*/
public function embed($file)
{
$this->email->embedFromPath($file);
$this->message->embedFromPath($file);

return $this;
}
Expand All @@ -265,7 +265,7 @@ public function embed($file)
*/
public function embedData($data, $name, $contentType = null)
{
$this->email->embed($data, $name, $contentType);
$this->message->embed($data, $name, $contentType);

return $this;
}
Expand All @@ -277,7 +277,7 @@ public function embedData($data, $name, $contentType = null)
*/
public function getSymfonyMessage()
{
return $this->email;
return $this->message;
}

/**
Expand Down
0