<?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() { $akSp2 = modstart_config(); config(array('mail' => array('driver' => 'smtp', 'host' => $akSp2->getWithEnv('systemEmailSmtpServer'), 'port' => $akSp2->getWithEnv('systemEmailSmtpSsl', false) ? 465 : 25, 'encryption' => $akSp2->getWithEnv('systemEmailSmtpSsl', false) ? 'ssl' : 'tls', 'from' => array('address' => $akSp2->getWithEnv('systemEmailSmtpUser'), 'name' => $akSp2->getWithEnv('systemEmailFromName', $akSp2->getWithEnv('siteName') . ' @ ' . $akSp2->getWithEnv('siteDomain'))), 'username' => $akSp2->getWithEnv('systemEmailSmtpUser'), 'password' => $akSp2->getWithEnv('systemEmailSmtpPassword')))); } public function name() { return 'smtp'; } public function send($dRXuh, $b2BhF, $vGHhs, $n16LT, $qOrzw = array()) { try { Mail::send(array(), array(), function ($vmVac) use($dRXuh, $b2BhF, $vGHhs, $n16LT) { if (ModStart::env() == 'laravel5') { $vmVac->setTo($dRXuh, $b2BhF)->setBody($n16LT, 'text/html')->setSubject($vGHhs); } else { $vmVac->to($dRXuh, $b2BhF)->subject($vGHhs)->html($n16LT); } }); return Response::generateSuccess(); } catch (\Exception $ZemkG) { return Response::generateError('ERROR:' . $ZemkG->getMessage()); } } }