diff --git a/.env.example b/.env.example index e1365d0c9..6d1fe260b 100644 --- a/.env.example +++ b/.env.example @@ -5,8 +5,8 @@ baseUrl = 'https://www.google.com' // 站点地址 timeZone = 'PRC' // RPC 天朝时间 UTC 格林时间 pwdMethod = 'md5' // 密码加密 可选 md5,sha256 salt = '' // 密码加密用,从旧版升级请留空 -theme' = 'default' // 主题 -authDriver' = 'redis' // 登录验证存储方式,推荐使用Redis support cookie,redis +theme = 'default' // 主题 +authDriver = 'redis' // 登录验证存储方式,推荐使用Redis 可选: cookie,redis // 邮件 mailDriver = 'mailgun' // mailgun or smtp @@ -37,3 +37,15 @@ redis_scheme = 'tcp' redis_host = '127.0.0.1' redis_port = '6379' redis_database = '0' + +# mailgun +mailgun_key = '' +mailgun_domain = '' +mailgun_sender = '' + +# smtp +smtp_host = '' +smtp_username = '' +smtp_port = '' +smtp_name = '' +smtp_sender = '' \ No newline at end of file diff --git a/app/Services/Mail/Mailgun.php b/app/Services/Mail/Mailgun.php index 272094634..1dd4718da 100755 --- a/app/Services/Mail/Mailgun.php +++ b/app/Services/Mail/Mailgun.php @@ -10,12 +10,20 @@ class Mailgun private $config,$mg,$domain,$sender; public function __construct(){ - $this->config = Config::get("mail")["mailgun"]; + $this->config = $this->getConfig(); $this->mg = new MailgunService($this->config["key"]); $this->domain = $this->config["domain"]; $this->sender = $this->config["sender"]; } + public function getConfig(){ + return [ + "key" => Config::get('mailgun_key'), + "domain" => Config::get('mailgun_domain'), + "sender" => Config::get('mailgun_sender') + ]; + } + public function send($to,$subject,$text){ $this->mg->sendMessage($this->domain, array('from' => $this->sender, 'to' => $to, diff --git a/app/Services/Mail/Smtp.php b/app/Services/Mail/Smtp.php index bd86a045d..d5826876c 100755 --- a/app/Services/Mail/Smtp.php +++ b/app/Services/Mail/Smtp.php @@ -12,7 +12,7 @@ class Smtp private $mail,$config; public function __construct(){ - $this->config = Config::get("mail")["smtp"]; + $this->config = $this->getConfig(); $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP @@ -26,6 +26,16 @@ public function __construct(){ $this->mail = $mail; } + public function getConfig(){ + return [ + "host" => Config::get('smtp_host'), + "username" => Config::get('smtp_username'), + "port" => Config::get('smtp_port'), + "sender" => Config::get('smtp_sender'), + "name" => Config::get('smtp_name') + ]; + } + public function send($to,$subject,$text){ $mail = $this->mail; $mail->addAddress($to); // Add a recipient