mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 23:03:25 +09:00
Remove trailing whitespace
This commit is contained in:
parent
3b0030e82b
commit
a9f72a5cd2
81 changed files with 2455 additions and 2455 deletions
|
|
@ -11,54 +11,54 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
* The API URL.
|
||||
*/
|
||||
protected static $_url = 'https://api.sendgrid.com/v3/mail/send';
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of configuration fields required by this mail driver.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getRequiredConfig()
|
||||
{
|
||||
return array('api_token');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SPF hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSPFHint()
|
||||
{
|
||||
return 'include:sendgrid.net';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the DKIM hint.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDKIMHint()
|
||||
{
|
||||
return 'smtpapi._domainkey';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the current mail driver is supported on this server.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
*
|
||||
* This method returns true on success and false on failure.
|
||||
*
|
||||
*
|
||||
* @param object $message
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -70,11 +70,11 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$message->errors[] = 'SendGrid: Please use API key (token) instead of username and password.';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Initialize the request data.
|
||||
$data = [];
|
||||
$data['personalizations'] = [];
|
||||
|
||||
|
||||
// Assemble the list of recipients.
|
||||
$to_list = [];
|
||||
if ($to = $message->message->getTo())
|
||||
|
|
@ -103,7 +103,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
}
|
||||
$data['personalizations'][] = ['bcc' => $bcc_list];
|
||||
}
|
||||
|
||||
|
||||
// Set the sender information.
|
||||
$from = $message->message->getFrom();
|
||||
if ($from)
|
||||
|
|
@ -114,21 +114,21 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$data['from']['name'] = array_first($from);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set the Reply-To address.
|
||||
$replyTo = $message->message->getReplyTo();
|
||||
if ($replyTo)
|
||||
{
|
||||
$data['reply_to']['email'] = array_first_key($from);
|
||||
}
|
||||
|
||||
|
||||
// Set the subject.
|
||||
$data['subject'] = strval($message->getSubject()) ?: 'Title';
|
||||
|
||||
|
||||
// Set the body.
|
||||
$data['content'][0]['type'] = $message->getContentType();
|
||||
$data['content'][0]['value'] = $message->getBody();
|
||||
|
||||
|
||||
// Add attachments.
|
||||
foreach ($message->getAttachments() as $attachment)
|
||||
{
|
||||
|
|
@ -142,7 +142,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
}
|
||||
$data['attachments'][] = $file_info;
|
||||
}
|
||||
|
||||
|
||||
// Prepare data and options for Requests.
|
||||
$headers = array(
|
||||
'Authorization' => 'Bearer ' . $this->_config['api_token'],
|
||||
|
|
@ -152,11 +152,11 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
'timeout' => 8,
|
||||
'useragent' => 'PHP',
|
||||
);
|
||||
|
||||
|
||||
// Send the API request.
|
||||
$request = \Requests::post(self::$_url, $headers, json_encode($data), $options);
|
||||
$response_code = intval($request->status_code);;
|
||||
|
||||
|
||||
// Parse the result.
|
||||
if (!$response_code)
|
||||
{
|
||||
|
|
@ -168,7 +168,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
|||
$message->errors[] = 'SendGrid: Response code ' . $response_code . ': ' . $request->body;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue