<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\EmailSmtp\Provider; use Illuminate\Support\Facades\Mail; use ModStart\Core\Input\Response; use ModStart\ModStart; use Module\Vendor\Provider\MailSender\AbstractMailSenderProvider; class SmtpMailSenderProvider extends AbstractMailSenderProvider { const NAME = 'smtp'; public function __construct() { $XhVgh = modstart_config(); config(array('mail' => array('driver' => 'smtp', 'host' => $XhVgh->getWithEnv('systemEmailSmtpServer'), 'port' => $XhVgh->getWithEnv('systemEmailSmtpSsl', false) ? 465 : 25, 'encryption' => $XhVgh->getWithEnv('systemEmailSmtpSsl', false) ? 'ssl' : 'tls', 'from' => array('address' => $XhVgh->getWithEnv('systemEmailSmtpUser'), 'name' => $XhVgh->getWithEnv('systemEmailFromName', $XhVgh->getWithEnv('siteName') . ' @ ' . $XhVgh->getWithEnv('siteDomain'))), 'username' => $XhVgh->getWithEnv('systemEmailSmtpUser'), 'password' => $XhVgh->getWithEnv('systemEmailSmtpPassword')))); } public function name() { return 'smtp'; } public function send($c6i2z, $LnjH9, $xcAHX, $eTwx_, $KJ3xr = array()) { try { Mail::send(array(), array(), function ($HMHj9) use($c6i2z, $LnjH9, $xcAHX, $eTwx_) { if (ModStart::env() == 'laravel5') { $HMHj9->setTo($c6i2z, $LnjH9)->setBody($eTwx_, 'text/html')->setSubject($xcAHX); } else { $HMHj9->to($c6i2z, $LnjH9)->subject($xcAHX)->html($eTwx_); } }); return Response::generateSuccess(); } catch (\Exception $hSVcc) { return Response::generateError('ERROR:' . $hSVcc->getMessage()); } } }