majiameng /
phpMailer
| 1 | <?php |
||
| 2 | namespace tinymeng\mailer; |
||
| 3 | |||
| 4 | /** |
||
| 5 | * Class Name: PHP Mailer类 |
||
| 6 | * @author Tinymeng <[email protected]> |
||
| 7 | * @date: 2019/9/26 16:49 |
||
| 8 | * @method static \tinymeng\mailer\Gateways\Smtp smtp(array $config) SMTP发送邮件 |
||
| 9 | * @package tinymeng\mailer |
||
| 10 | */ |
||
| 11 | class Email |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Description: init |
||
| 15 | * @author: JiaMeng <[email protected]> |
||
| 16 | * Updater: |
||
| 17 | * @param $gateway |
||
| 18 | * @param null $config |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 19 | * @return mixed |
||
| 20 | * @throws \Exception |
||
| 21 | */ |
||
| 22 | protected static function init($gateway, $config = null) |
||
| 23 | { |
||
| 24 | $class = __NAMESPACE__ . '\\Gateways\\' . ucfirst(strtolower($gateway)); |
||
| 25 | if (class_exists($class)) { |
||
| 26 | $app = new $class($config); |
||
| 27 | return $app; |
||
| 28 | } |
||
| 29 | throw new \Exception("发送Mailer基类 [$gateway] 不存在"); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Description: __callStatic |
||
| 34 | * @author: JiaMeng <[email protected]> |
||
| 35 | * Updater: |
||
| 36 | * @param $gateway |
||
| 37 | * @param $config |
||
| 38 | * @return mixed |
||
| 39 | */ |
||
| 40 | public static function __callStatic($gateway, $config) |
||
| 41 | { |
||
| 42 | return self::init($gateway, ...$config); |
||
| 43 | } |
||
| 44 | |||
| 45 | } |
||
| 46 |