The example in this article describes how CodeIgniter uses the SMTP service to send HTML messages. Share to everyone for your reference. Specifically as follows:
CodeIgniter provides an email class for sending mail,
Wiki address: http://codeigniter.org.cn/user_guide/libraries/email.html
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 under the Config folder,
For email.php configuration, there are several points to note:
1 The general test use of the SMTP service, such as 126, 163 of the mailboxes are used this protocol, so protocol select SMTP
2 Enterprise marketing mail is generally HTML, at this point, you need to configure Mailtype for HTML
The email.php configuration file I wrote under the example:
<?php
if (! 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 values using the HTML that needs to be handled
$send _msg = str_replace ("\" "," ", $msg);
$this->email->message ($send _msg);
3 when developing, it is recommended that you turn on debug information, because if you use 126 of your mailbox frequently to send messages externally,
One may be considered spam and, more important, it may be blocked by 126:(
I hope this article will help you with the PHP program design based on CodeIgniter.