CodeIgniter method _php instance for sending HTML messages using the SMTP service

Source: Internet
Author: User
Tags codeigniter
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.