Home > Backend Development > PHP Tutorial > CI框架简单邮件发送类实例_PHP

CI框架简单邮件发送类实例_PHP

WBOY
Release: 2016-05-27 10:15:37
Original
841 people have browsed it

本文实例讲述了CI框架简单邮件发送类。分享给大家供大家参考,具体如下:

ci框架绝对是php初学中想要的东西,它能极大的缩短你的代码量!

下面看看我的发送邮件的简单演示:

function email()
{
   $this->load->library('email');
   $config['protocol'] = 'smtp';
   $config['smtp_host'] = 'smtp.163.com';
   $config['smtp_user'] = 'jb51@163.com';//这里写上你的163邮箱账户
   $config['smtp_pass'] = 'jb51;';//这里写上你的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('jb51@163.com', '');//发件人
   $this->email->to('123456789@qq.com');
   $this->email->message('哈哈,测试邮件发送');
   $this->email->send();
   echo $this->email->print_debugger();
}

Copy after login

如果您不想使用使用上述方法设定参数,您可以把它们放入一个配置文件。创建一个新文件称为email.php,添加$config数组在该文件中。然后将该文件保存为config/email.php 它将自动的被使用。如果您保存了一个参数配置文件,就不需要使用$this->email->initialize()函数来初始化参数了

更多关于CodeIgniter相关内容感兴趣的读者可查看本站专题:《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《php优秀开发框架总结》、《ThinkPHP入门教程》、《ThinkPHP常用方法总结》、《Zend FrameWork框架入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于CodeIgniter框架的PHP程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template