SmsModel::sendEmaillCaptcha PHP Method

sendEmaillCaptcha() public method

发送验证码到邮箱
Author: Medz Seven ([email protected])
public sendEmaillCaptcha ( string $email, boolean $sendLock = false ) : boolean
$email string 邮箱地址
$sendLock boolean 是否有时间锁
return boolean
    public function sendEmaillCaptcha($email, $sendLock = false)
    {
        $this->phone = $email;
        /* # 判断是否是email */
        if (!preg_match("/^\\w+(?:[-+.']\\w+)*@\\w+(?:[-.]\\w+)*\\.\\w+(?:[-.]\\w+)*\$/", $email)) {
            $this->setMessage('邮箱格式不正确');
            return false;
        } elseif ($sendLock and $this->lock()) {
            return false;
        }
        $site = model('Xdata')->get('admin_Config:site');
        $email = model('Mail');
        $title = ${$GLOBALS}['ts']['site']['site_name'] . '验证码';
        $body = '您的验证码是:' . $this->code;
        $body = '<style>a.email_btn,a.email_btn:link,a.email_btn:visited{background:#0F8CA8;padding:5px 10px;color:#fff;width:80px;text-align:center;}</style><div style="width:540px;border:#0F8CA8 solid 2px;margin:0 auto"><div style="color:#bbb;background:#0f8ca8;padding:5px;overflow:hidden;zoom:1"><div style="float:right;height:15px;line-height:15px;padding:10px 0;display:none">2012年07月15日</div>
					<div style="float:left;overflow:hidden;position:relative"><a><img style="border:0 none" src="' . $GLOBALS['ts']['site']['site_logo'] . '"></a></div></div>
					<div style="background:#fff;padding:20px;min-height:300px;position:relative">		<div style="font-size:14px;">
						            	<p style="padding:0 0 20px;margin:0;font-size:12px">' . $body . '</p>
						            </div></div><div style="background:#fff;">
			            <div style="text-align:center;height:18px;line-height:18px;color:#999;padding:6px 0;font-size:12px">若不想再收到此类邮件,请点击<a href="' . U('public/Account/notify') . '" style="text-decoration:none;color:#3366cc">设置</a></div>
			            <div style="line-height:18px;text-align:center"><p style="color:#999;font-size:12px">' . $site['site_footer'] . '</p></div>
			        </div></div>';
        if ($email->send_email($this->phone, $title, $body)) {
            $this->InLock();
            $this->add(array('phone' => $this->phone, 'code' => $this->code, 'time' => time()));
            return true;
        }
        $this->setMessage($email->message);
        return false;
    }