mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 20:44:28 +09:00
Standardize config field names, and make drivers declare which fields they require
This commit is contained in:
parent
4d1ada5f28
commit
10309e5811
6 changed files with 99 additions and 5 deletions
|
|
@ -46,6 +46,26 @@ abstract class Base implements \Rhymix\Framework\Drivers\MailInterface
|
||||||
return class_basename(get_called_class());
|
return class_basename(get_called_class());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of configuration fields required by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getRequiredConfig()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of API types supported by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getAPITypes()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current mail driver is supported on this server.
|
* Check if the current mail driver is supported on this server.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,32 @@ class SES extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
||||||
*/
|
*/
|
||||||
protected function __construct(array $config)
|
protected function __construct(array $config)
|
||||||
{
|
{
|
||||||
$transport = \Swift_AWSTransport::newInstance($config['user'], $config['pass']);
|
$transport = \Swift_AWSTransport::newInstance($config['api_user'], $config['api_pass']);
|
||||||
$transport->setDebug(array($this, 'debugCallback'));
|
$transport->setDebug(array($this, 'debugCallback'));
|
||||||
$transport->setEndpoint('https://email.' . strtolower($config['type']) . '.amazonaws.com/');
|
$transport->setEndpoint('https://email.' . strtolower($config['api_type']) . '.amazonaws.com/');
|
||||||
$this->mailer = \Swift_Mailer::newInstance($transport);
|
$this->mailer = \Swift_Mailer::newInstance($transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of configuration fields required by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getRequiredConfig()
|
||||||
|
{
|
||||||
|
return array('api_user', 'api_pass', 'api_type');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of API types supported by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getAPITypes()
|
||||||
|
{
|
||||||
|
return array('us-east-1', 'us-west-2', 'eu-west-1');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current mail driver is supported on this server.
|
* Check if the current mail driver is supported on this server.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ class SMTP extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
||||||
*/
|
*/
|
||||||
protected function __construct(array $config)
|
protected function __construct(array $config)
|
||||||
{
|
{
|
||||||
$transport = \Swift_SmtpTransport::newInstance($config['host'], $config['port'], $config['secure']);
|
$transport = \Swift_SmtpTransport::newInstance($config['smtp_host'], $config['smtp_port'], $config['smtp_security']);
|
||||||
$transport->setUsername($config['user']);
|
$transport->setUsername($config['smtp_user']);
|
||||||
$transport->setPassword($config['pass']);
|
$transport->setPassword($config['smtp_pass']);
|
||||||
$local_domain = $transport->getLocalDomain();
|
$local_domain = $transport->getLocalDomain();
|
||||||
if (preg_match('/^\*\.(.+)$/', $local_domain, $matches))
|
if (preg_match('/^\*\.(.+)$/', $local_domain, $matches))
|
||||||
{
|
{
|
||||||
|
|
@ -23,6 +23,16 @@ class SMTP extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
||||||
$this->mailer = \Swift_Mailer::newInstance($transport);
|
$this->mailer = \Swift_Mailer::newInstance($transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of configuration fields required by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getRequiredConfig()
|
||||||
|
{
|
||||||
|
return array('smtp_host', 'smtp_port', 'smtp_security', 'smtp_user', 'smtp_pass');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current mail driver is supported on this server.
|
* Check if the current mail driver is supported on this server.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,16 @@ class SparkPost extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
||||||
*/
|
*/
|
||||||
protected static $_url = 'https://api.sparkpost.com/api/v1/transmissions';
|
protected static $_url = 'https://api.sparkpost.com/api/v1/transmissions';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of configuration fields required by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getRequiredConfig()
|
||||||
|
{
|
||||||
|
return array('api_token');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current mail driver is supported on this server.
|
* Check if the current mail driver is supported on this server.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,26 @@ class Woorimail extends Base implements \Rhymix\Framework\Drivers\MailInterface
|
||||||
'me_013' => '전용채널에 도메인이 등록되어 있지 않습니다.',
|
'me_013' => '전용채널에 도메인이 등록되어 있지 않습니다.',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of configuration fields required by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getRequiredConfig()
|
||||||
|
{
|
||||||
|
return array('api_domain', 'api_token', 'api_type');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of API types supported by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getAPITypes()
|
||||||
|
{
|
||||||
|
return array('free', 'paid');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current mail driver is supported on this server.
|
* Check if the current mail driver is supported on this server.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,20 @@ interface MailInterface
|
||||||
*/
|
*/
|
||||||
public static function getName();
|
public static function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of configuration fields required by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getRequiredConfig();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of API types supported by this mail driver.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getAPITypes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current mail driver is supported on this server.
|
* Check if the current mail driver is supported on this server.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue