/**
** 邮箱发送验证码
**/
public function emailSend($email){
// $cachekey = FunctionsUtil::encrypt($email . __CLASS__ . __FUNCTION__);
// $items = yii::$app->cache->get($cachekey);
$title = '买时间用户绑定';
$code = mt_rand(100000,999999);
$msg = "{$code} (绑定邮箱验证码)";//发送信息
// $emailfrom = ['do-not-replay@buyevery.cn' => '买时间'];//发送者
if(empty($email)){
return false;
}
$mail= Yii::$app->mailer->compose();
// $mail->setFrom($emailfrom);
$mail->setTo($email);
$mail->setSubject($title);
// $mail->setTextBody('zheshisha '); //发布纯文字文本
$mail->setHtmlBody($msg); //发布可以带html标签的文本
if($mail->send()){
//发送记录
// yii::$app->cache->set($cachekey, ++$items, $this->lifeTime);
//保存code到session中
yii::$app->session->set('sms_verify', array('verify_code'=>FunctionsUtil::encrypt($code), 'verify_time'=>time()));
//记录短信业务日志
//LogUtil::Log('send', $type.' '.$phone.' '.$msg);
return true;
}
else{
// var_dump($mail->errors());exit;
return false;
}
}
---- 参考文件------