CI邮件发送

//以下为一个简单的发送函数:

 function email()

 {
    $this->load->library('email');
      $config['protocol'] = 'smtp';
      $config['smtp_host'] = 'smtp.163.com';
      $config['smtp_user'] = 'phpddt1990@163.com';//这里写上你的163邮箱账户
      $config['smtp_pass'] = 'phpddt;';//这里写上你的163邮箱密码
      $config['mailtype'] = 'html';
      $config['validate'] = true;
      $config['priority'] = 1;
     $config['crlf']  = "\r\n";
     $config['smtp_port'] = 25;
     $config['charset'] = 'utf-8';
     $config['wordwrap'] = TRUE;
    
     $this->email->initialize($config);
    
    
     $this->email->from('phpddt1990@163.com', '合肥学院青年志愿者联合会');//发件人
     $this->email->to('987044391@qq.com');
    
      $this->email->message('哈哈,测试邮件发送');
      $this->email->send();
      echo $this->email->print_debugger();
 
}

//下面研究怎么发送html邮件:

    $config['mailtype'] = 'html';    //这样设置为HTML类型

   $this->email->message('<font color=red>Testing the email class.</font>'); 

 试一下就知道可以了!

//利用邮件模板发送邮件

 邮件模板一般是存放在数据库当中的,只要根据模版名称在相应的数据库中查找出对应的模版

并替换掉相关的变量即可。

如以下这样一个函数:

$type代表模板名称,$replace为要替换的变量值

getEmailTemplateByType ( $type, $replace = array())


该函数一般放在公共函数库当中。







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值