This article describes the CI framework simple email sending class example. Share it with everyone for your reference, the details are as follows:
The CI framework is definitely what you want when you are a beginner in PHP. It can greatly shorten the amount of your code!
Look at my simple demonstration of sending an email below:
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(); }
If you don’t want to set parameters using the above method, you can put them into a configuration file. Create a new file called email.php and add the $config array in the file. Then save the file as config/email.php and it will be used automatically. If you save a parameter configuration file, you do not need to use the $this->email->initialize() function to initialize the parameters
Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php excellent development framework summary", "ThinkPHP introductory tutorial", "Summary of Common Methods in ThinkPHP", "Introduction Tutorial on Zend FrameWork Framework", "Introduction Tutorial on PHP Object-Oriented Programming", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.