手机
当前位置:查字典教程网 >编程开发 >php教程 >CodeIgniter使用smtp服务发送html邮件的方法
CodeIgniter使用smtp服务发送html邮件的方法
摘要:本文实例讲述了CodeIgniter使用smtp服务发送html邮件的方法。分享给大家供大家参考。具体如下:codeigniter提供的em...

本文实例讲述了CodeIgniter使用smtp服务发送html邮件的方法。分享给大家供大家参考。具体如下:

codeigniter 提供的email类,用于发送邮件,

wiki地址: http://codeigniter.org.cn/user_guide/libraries/email.html

实际开发中遇到以下几个问题,总结一下:

1. wiki中说明是可以将配置文件单独提出来,email.php 放置到config文件夹下,

对于email.php 的配置,需要说明的几点:

1) 一般测试使用的smtp服务,如126、163 的邮箱均采用此协议,故 protocol 选择 smtp

2) 企业营销邮件一般都是html的,此时,需要配置mailtype 为 html

示例下我写的email.php 配置文件:

<?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) 发送的html 属性值使用的html,需要处理一下

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

3) 开发时,建议打开debug信息,因为如果你频繁使用126的邮箱对外发送邮件,

一来可能会被认为是垃圾邮件,更主要的是可能被126封杀掉 :(

希望本文所述对大家基于CodeIgniter的php程序设计有所帮助。

【CodeIgniter使用smtp服务发送html邮件的方法】相关文章:

thinkphp3.2中Lite文件替换框架入口文件或应用入口文件的方法

WINDOWS服务器安装多套PHP的另类解决方案

一个简单的自动发送邮件系统(三)

php使用for语句输出三角形的方法

PHP获取文件行数的方法

php递归调用删除数组空值元素的方法

php采集中国代理服务器网的方法

php使用array_search函数实现数组查找的方法

php恢复数组的key为数字序列的方法

php实现将上传word文件转为html的方法

精品推荐
分类导航