ヤミRoot VoidGate
User / IP
:
216.73.216.143
Host / Server
:
146.88.233.70 / dev.loger.cm
System
:
Linux hybrid1120.fr.ns.planethoster.net 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
logercm
/
dev.loger.cm
/
fixtures
/
assert
/
Viewing: sendgrid-mailer.tar
Transport/SendgridApiTransport.php 0000644 00000015664 15120140745 0013372 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mailer\Bridge\Sendgrid\Transport; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Mailer\Envelope; use Symfony\Component\Mailer\Exception\HttpTransportException; use Symfony\Component\Mailer\Exception\TransportException; use Symfony\Component\Mailer\Header\MetadataHeader; use Symfony\Component\Mailer\Header\TagHeader; use Symfony\Component\Mailer\SentMessage; use Symfony\Component\Mailer\Transport\AbstractApiTransport; use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Email; use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; /** * @author Kevin Verschaeve */ class SendgridApiTransport extends AbstractApiTransport { private const HOST = 'api.sendgrid.com'; private $key; public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null) { $this->key = $key; parent::__construct($client, $dispatcher, $logger); } public function __toString(): string { return sprintf('sendgrid+api://%s', $this->getEndpoint()); } protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $envelope): ResponseInterface { $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/v3/mail/send', [ 'json' => $this->getPayload($email, $envelope), 'auth_bearer' => $this->key, ]); try { $statusCode = $response->getStatusCode(); } catch (TransportExceptionInterface $e) { throw new HttpTransportException('Could not reach the remote Sendgrid server.', $response, 0, $e); } if (202 !== $statusCode) { try { $result = $response->toArray(false); throw new HttpTransportException('Unable to send an email: '.implode('; ', array_column($result['errors'], 'message')).sprintf(' (code %d).', $statusCode), $response); } catch (DecodingExceptionInterface $e) { throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).sprintf(' (code %d).', $statusCode), $response, 0, $e); } } $sentMessage->setMessageId($response->getHeaders(false)['x-message-id'][0]); return $response; } private function getPayload(Email $email, Envelope $envelope): array { $addressStringifier = function (Address $address) { $stringified = ['email' => $address->getAddress()]; if ($address->getName()) { $stringified['name'] = $address->getName(); } return $stringified; }; $payload = [ 'personalizations' => [], 'from' => $addressStringifier($envelope->getSender()), 'content' => $this->getContent($email), ]; if ($email->getAttachments()) { $payload['attachments'] = $this->getAttachments($email); } $personalization = [ 'to' => array_map($addressStringifier, $this->getRecipients($email, $envelope)), 'subject' => $email->getSubject(), ]; if ($emails = array_map($addressStringifier, $email->getCc())) { $personalization['cc'] = $emails; } if ($emails = array_map($addressStringifier, $email->getBcc())) { $personalization['bcc'] = $emails; } if ($emails = array_map($addressStringifier, $email->getReplyTo())) { // Email class supports an array of reply-to addresses, // but SendGrid only supports a single address $payload['reply_to'] = $emails[0]; } $customArguments = []; $categories = []; // these headers can't be overwritten according to Sendgrid docs // see https://sendgrid.api-docs.io/v3.0/mail-send/mail-send-errors#-Headers-Errors $headersToBypass = ['x-sg-id', 'x-sg-eid', 'received', 'dkim-signature', 'content-transfer-encoding', 'from', 'to', 'cc', 'bcc', 'subject', 'content-type', 'reply-to']; foreach ($email->getHeaders()->all() as $name => $header) { if (\in_array($name, $headersToBypass, true)) { continue; } if ($header instanceof TagHeader) { if (10 === \count($categories)) { throw new TransportException(sprintf('Too many "%s" instances present in the email headers. Sendgrid does not accept more than 10 categories on an email.', TagHeader::class)); } $categories[] = mb_substr($header->getValue(), 0, 255); } elseif ($header instanceof MetadataHeader) { $customArguments[$header->getKey()] = $header->getValue(); } else { $payload['headers'][$header->getName()] = $header->getBodyAsString(); } } if (\count($categories) > 0) { $payload['categories'] = $categories; } if (\count($customArguments) > 0) { $personalization['custom_args'] = $customArguments; } $payload['personalizations'][] = $personalization; return $payload; } private function getContent(Email $email): array { $content = []; if (null !== $text = $email->getTextBody()) { $content[] = ['type' => 'text/plain', 'value' => $text]; } if (null !== $html = $email->getHtmlBody()) { $content[] = ['type' => 'text/html', 'value' => $html]; } return $content; } private function getAttachments(Email $email): array { $attachments = []; foreach ($email->getAttachments() as $attachment) { $headers = $attachment->getPreparedHeaders(); $filename = $headers->getHeaderParameter('Content-Disposition', 'filename'); $disposition = $headers->getHeaderBody('Content-Disposition'); $att = [ 'content' => str_replace("\r\n", '', $attachment->bodyToString()), 'type' => $headers->get('Content-Type')->getBody(), 'filename' => $filename, 'disposition' => $disposition, ]; if ('inline' === $disposition) { $att['content_id'] = $filename; } $attachments[] = $att; } return $attachments; } private function getEndpoint(): ?string { return ($this->host ?: self::HOST).($this->port ? ':'.$this->port : ''); } } Transport/SendgridSmtpTransport.php 0000644 00000001466 15120140745 0013577 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mailer\Bridge\Sendgrid\Transport; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; /** * @author Kevin Verschaeve */ class SendgridSmtpTransport extends EsmtpTransport { public function __construct(string $key, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null) { parent::__construct('smtp.sendgrid.net', 465, true, $dispatcher, $logger); $this->setUsername('apikey'); $this->setPassword($key); } } Transport/SendgridTransportFactory.php 0000644 00000003023 15120140745 0014252 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Mailer\Bridge\Sendgrid\Transport; use Symfony\Component\Mailer\Exception\UnsupportedSchemeException; use Symfony\Component\Mailer\Transport\AbstractTransportFactory; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Transport\TransportInterface; /** * @author Konstantin Myakshin <molodchick@gmail.com> */ final class SendgridTransportFactory extends AbstractTransportFactory { public function create(Dsn $dsn): TransportInterface { $scheme = $dsn->getScheme(); $key = $this->getUser($dsn); if ('sendgrid+api' === $scheme) { $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); $port = $dsn->getPort(); return (new SendgridApiTransport($key, $this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port); } if ('sendgrid+smtp' === $scheme || 'sendgrid+smtps' === $scheme || 'sendgrid' === $scheme) { return new SendgridSmtpTransport($key, $this->dispatcher, $this->logger); } throw new UnsupportedSchemeException($dsn, 'sendgrid', $this->getSupportedSchemes()); } protected function getSupportedSchemes(): array { return ['sendgrid', 'sendgrid+api', 'sendgrid+smtp', 'sendgrid+smtps']; } } CHANGELOG.md 0000644 00000000753 15120140745 0006361 0 ustar 00 CHANGELOG ========= 5.4 --- * Add support for `TagHeader` and `MetadataHeader` to the Sendgrid API transport 4.4.0 ----- * [BC BREAK] Renamed and moved `Symfony\Component\Mailer\Bridge\Sendgrid\Http\Api\SendgridTransport` to `Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridApiTransport`, `Symfony\Component\Mailer\Bridge\Sendgrid\Smtp\SendgridTransport` to `Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridSmtpTransport`. 4.3.0 ----- * Added the bridge LICENSE 0000644 00000002054 15120140745 0005551 0 ustar 00 Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. README.md 0000644 00000001051 15120140745 0006017 0 ustar 00 Sendgrid Bridge =============== Provides Sendgrid integration for Symfony Mailer. Configuration example: ```env # SMTP MAILER_DSN=sendgrid+smtp://KEY@default # API MAILER_DSN=sendgrid+api://KEY@default ``` where: - `KEY` is your Sendgrid API Key Resources --------- * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) composer.json 0000644 00000001542 15120140745 0007267 0 ustar 00 { "name": "symfony/sendgrid-mailer", "type": "symfony-mailer-bridge", "description": "Symfony Sendgrid Mailer Bridge", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": ">=7.2.5", "psr/event-dispatcher": "^1", "symfony/mailer": "^5.4.21|^6.2.7" }, "require-dev": { "symfony/http-client": "^4.4|^5.0|^6.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Sendgrid\\": "" }, "exclude-from-classmap": [ "/Tests/" ] }, "minimum-stability": "dev" }
Coded With 💗 by
0x6ick