欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP发送邮件确认验证注册功能示例【修改别人邮件类】

程序员文章站 2023-11-24 21:17:04
本文实例讲述了php发送邮件确认验证注册功能。分享给大家供大家参考,具体如下: 类库: require "class.phpmailer.php"; require...

本文实例讲述了php发送邮件确认验证注册功能。分享给大家供大家参考,具体如下:

类库:

PHP发送邮件确认验证注册功能示例【修改别人邮件类】

require "class.phpmailer.php";
require "class.smtp.php";
class php_mailer
{
 protected $mail;
 public function __construct()
 {
  $mail = new phpmailer;
  $mail->smtpdebug = 3;       
  $mail->issmtp();         
  $mail->smtpauth = true;       
  $mail->ishtml(true); 
  $ci =& get_instance();
  $ci->load->config('email_config');
  $email = $ci->config->item('email');
  foreach ($email as $key => $value) {
   $mail->$key = $value;
  }
  $this->mail = $mail;
 }
 public function check_user($email,$nick,$txt,$id)
 {
  $this->mail->fromname = '表白墙';
  $this->mail->addaddress("$email");  // add a recipient
  $this->mail->addreplyto('test@test.com', '表白墙反馈');
  $this->mail->subject = '表白墙通知';
  $this->mail->charset = "utf-8";
  $this->mail->body = <<<body
<p>你好:测试邮件
body;
  $this->mail->altbody = <<<altbody
你好:
有一个altbody说:谢谢许愿墙的程序员 敬上! altbody; if ($this->mail->send()) { returntrue; } elsereturnfalse; } }

调用

$this->load->library('email/php_mailer');
$result = $this->php_mailer->check_user('297538600@qq.com', 'aaa', '$row->txt', '$row->id');
if ($result == true) {
 //更新状态
 echo 'ok';
}

待完善接收邮件验证的功能

邮件类下载地址: