The example in this article describes how CodeIgniter uses the SMTP service to send HTML messages. Share to everyone for your reference. Specific as follows:
CodeIgniter provides an email class for sending mail,
Wiki address: http://codeigniter.org.cn/user_guide/libraries/email.html
In the actual development encountered the following several problems, summed up:
1. The wiki indicates that the configuration file can be presented separately, email.php placed in the Config folder,
For email.php configuration, there are several points to note:
1) The SMTP service used by the general test, such as 126, 163 of the mailbox is the use of this Protocol, so protocol select SMTP
2) Enterprise Marketing mail is generally HTML, at this time, you need to configure Mailtype for HTML
Example below 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 '] = ' + '; $config [' charset '] = ' utf-8 '; $config [' wordwrap '] = TRUE; $config [' Mailtype '] = ' html ';
2) Send HTML attribute value using HTML, need to deal with
$send _msg = str_replace ("\" "," ", $msg); $this->email->message ($send _msg);
3) When developing, it is recommended to open the debug information, because if you frequently use 126 of the mailbox to send external mail,
One may be considered spam, and more likely to be blocked by 126:(
I hope this article is helpful to everyone based on CodeIgniter PHP program design.