Home  >  Article  >  Backend Development  >  CodeIgniter uses smtp service to send html emails, codeignitersmtp_PHP tutorial

CodeIgniter uses smtp service to send html emails, codeignitersmtp_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:51:11783browse

CodeIgniter uses the smtp service to send html emails, codeignitersmtp

This article describes the example of CodeIgniter using the smtp service to send html emails. Share it with everyone for your reference. The details are as follows:

The email class provided by codeigniter is used to send emails,

Wiki address: http://codeigniter.org.cn/user_guide/libraries/email.html

In actual development, we encountered the following problems. To summarize:

1. The wiki explains that the configuration file can be extracted separately, and email.php is placed in the config folder,

For the configuration of email.php, there are a few points that need to be explained:

1) The smtp service used in general testing, such as the mailboxes of 126 and 163, all use this protocol, so the protocol is smtp

2) Corporate marketing emails are generally in html. In this case, you need to configure the mailtype to html

The email.php configuration file I wrote under the example:

<&#63;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'] = '25';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';

2) The html used in the sent html attribute value needs to be processed

$send_msg = str_replace("\"", "", $msg); 
$this->email->message($send_msg);  

3) When developing, it is recommended to turn on the debug information, because if you frequently use the 126 mailbox to send external emails,
Firstly, it may be considered as spam, and more importantly, it may be blocked by 126 :(

I hope this article will be helpful to everyone’s PHP programming based on CodeIgniter.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1014434.htmlTechArticleCodeIgniter uses the smtp service to send html emails, codeignitersmtp This article describes how CodeIgniter uses the smtp service to send html emails. . Share it with everyone for your reference. Tool...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn