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

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. 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.

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.