This article mainly introduces how CodeIgniter uses the smtp service to send html emails. it involves the use of email in CodeIgniter, for more information about how CodeIgniter uses the smtp service to send html emails, see the following example. Share it with you for your reference. The details are as follows:
The email class provided by codeigniter for sending emails,
Wiki address: http://codeigniter.org.cn/user_guide/libraries/email.html
Summary:
1. the wiki indicates that the configuration file can be submitted separately, and email. php can be placed in the config folder,
The configuration of email. php should be described as follows:
1) generally, the smtp service used for testing, such as 126 and 163 mailboxes all use this protocol, so protocol Selects smtp
2) Enterprise marketing emails are generally html. at this time, you need to configure mailtype as html
In the example, I wrote the email. php configuration file:
<?phpif ( ! defined('BASEPATH')) exit('No direct script access allowed'); /* |------------------------------------ | Email Config |------------------------------------ | by chaichunyan | */ $config['protocol'] = 'smtp';$config['smtp_host'] = 'smtp.126.com';$config['smtp_user'] = 'xxx@126.com';$config['smtp_pass'] = 'xxx';$config['smtp_port'] = '25';$config['charset'] = 'utf-8';$config['wordwrap'] = TRUE;$config['mailtype'] = 'html';
2) the sent html property value uses html, which needs to be processed.
$send_msg = str_replace("\"", "", $msg); $this->email->message($send_msg);
3) during development, we recommend that you enable the debug information, because if you frequently use 126 of emails,
First, it may be considered as spam, and more importantly, it may be blocked by 126 :(
I hope this article will help you with CodeIgniter-based php programming.