CodeIgniter使用smtp服务发送html邮件的方法
《PHP实战:CodeIgniter使用smtp服务发送html邮件的方法》要点: 本篇章节讲解CodeIgniter使用smtp服务发送html邮件的办法.分享给大家供大家参考.具体如下:PHP学习 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的邮箱对外发送邮件, 希望本文所述对大家基于CodeIgniter的php程序设计有所赞助. 《PHP实战:CodeIgniter使用smtp服务发送html邮件的方法》是否对您有启发,欢迎查看更多与《PHP实战:CodeIgniter使用smtp服务发送html邮件的方法》相关教程,学精学透。编程之家 52php.cn为您提供精彩教程。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |