8000 Backport option to enable Sandbox via dsn option sandbox=true to 5.4 by mdawart · Pull Request #49453 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Backport option to enable Sandbox via dsn option sandbox=true to 5.4 #49453

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 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
8000
Prev Previous commit
Next Next commit
Add option to enable Sandbox via dsn option sandbox=true
  • Loading branch information
mdawart committed Feb 17, 2023
commit 6e912d59ddfd54c217e7eb14c790470a07b45a38
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ class MailjetApiTransport extends AbstractApiTransport

private $privateKey;
private $publicKey;
private $sandbox;

public function __construct(string $publicKey, string $privateKey, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
public function __construct(string $publicKey, string $privateKey, bool $sandbox, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->publicKey = $publicKey;
$this->privateKey = $privateKey;
$this->sandbox = $sandbox;

parent::__construct($client, $dispatcher, $logger);
}
Expand Down Expand Up @@ -135,9 +137,15 @@ private function getPayload(Email $email, Envelope $envelope): array
$message['Headers'][$header->getName()] = $header->getBodyAsString();
}

return [
$returnArray = [
'Messages' => [$message],
];

if ($this->sandbox) {
$returnArray['SandboxMode']=true;
}

return $returnArray;
}

private function formatAddresses(array $addresses): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function create(Dsn $dsn): TransportInterface
$user = $this->getUser($dsn);
$password = $this->getPassword($dsn);
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
$sandbox = $dsn->getOption('sandbox') === 'true' ? true : false;
$sandbox = $dsn->getOption('sandbox') === 'true';

if ('mailjet+api' === $scheme) {
return (new MailjetApiTransport($user, $password, $sandbox, $this->client, $this->dispatcher, $this->logger))->setHost($host);
Expand Down
0