首页 > Web开发 > 详细

php使用CI发送qq和163邮件

时间:2017-01-04 12:52:12      阅读:554      评论:0      收藏:0      [点我收藏+]

1.需求

发送邮件

2.介绍

使用CI框架的email类库发送邮件,这里演示QQ和163

3.163使用教程

a.先去163邮件开启smtp邮件。

b.在CI的控制器里写下面的代码

$this->load->library(‘email‘);            //加载CI的email类


        $config[‘protocol‘] = ‘smtp‘;
        $config[‘smtp_host‘] = ‘smtp.163.com‘;
        $config[‘smtp_user‘] = ‘18367724000@163.com‘;//这里写上你的163邮箱账户
        $config[‘smtp_pass‘] = ‘storecode888‘;//这里写上你的163邮箱密码
        $config[‘mailtype‘] = ‘html‘;
        $config[‘validate‘] = true;
        $config[‘priority‘] = 1;
        $config[‘crlf‘]  = "\r\n";
        $config[‘smtp_port‘] = 25;
        $config[‘charset‘] = ‘utf-8‘;
        $config[‘wordwrap‘] = TRUE;
        $this->email->initialize($config);

        //以下设置Email内容
        $this->email->from(‘18367724000@163.com‘, ‘mike‘);
        $this->email->to(‘3090333013@qq.com‘);
        $this->email->subject(‘Email Test‘);
        $this->email->message(‘<font color=red>Testing the email class.</font>‘);
        $this->email->attach(‘application\controllers\1.jpeg‘);           //相对于index.php的路径

        $this->email->send();

4.QQ使用教程

a.先去qq邮件开启smtp邮件。

b.在CI的控制器里写下面的代码

$this->load->library(‘email‘);            //加载CI的email类

        //以下设置Email参数
        $config[‘protocol‘] = ‘smtp‘;
        $config[‘smtp_host‘] = ‘ssl://smtp.qq.com‘;
        $config[‘smtp_user‘] = ‘100000356@qq.com‘;
        $config[‘smtp_pass‘] = ‘dxwgjbziifqhbggj‘;
        $config[‘smtp_port‘] = ‘465‘;
        $config[‘charset‘] = ‘utf-8‘;
        $config[‘wordwrap‘] = TRUE;
        $config[‘mailtype‘] = ‘html‘;
        $config[‘newline‘] = PHP_EOL;
        $config[‘crlf‘] = PHP_EOL;
        $this->email->initialize($config);

        //以下设置Email内容
        $this->email->from(‘18367724000@163.com‘, ‘mike‘);
        $this->email->to(‘3090333013@qq.com‘);
        $this->email->subject(‘Email Test‘);
        $this->email->message(‘<font color=red>Testing the email class.</font>‘);
        $this->email->attach(‘application\controllers\1.jpeg‘);           //相对于index.php的路径

        $this->email->send();

 

5.总结

要注意先开启smtp功能才能发短信,密码是开启之后提供的,而不是邮件的登录密码。

 

参考资料:http://www.phpddt.com/mvc/79.html

https://www.ipbbs.net/viewtopic.php?pid=119

 

php使用CI发送qq和163邮件

原文:http://www.cnblogs.com/norm/p/6248072.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!