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