zoukankan      html  css  js  c++  java
  • php使用CI发送qq和163邮件

    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'] = 'storecode8881111';//这里写上你的163邮箱密码
            $config['mailtype'] = 'html';
            $config['validate'] = true;
            $config['priority'] = 1;
            $config['crlf']  = "
    ";
            $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('applicationcontrollers1.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('applicationcontrollers1.jpeg');           //相对于index.php的路径
    
            $this->email->send();

    阿里云ecs关闭25端口的,要用163的465端口来发送

      $this->load->library('email');            //加载CI的email类
            $smtp= $this->config->item("smtp");
            $config['protocol'] = 'smtp';
            $config['smtp_host'] = 'ssl://smtp.163.com';
            $config['smtp_user'] = $smtp['user'];//这里写上你的163邮箱账户
            $config['smtp_pass'] = $smtp['password'];//这里写上你的163邮箱密码
            $config['mailtype'] = 'html';
            $config['validate'] = true;
            $config['priority'] = 1;
            $config['crlf']  = "
    ";
            $config['smtp_port'] = 465;
            $config['charset'] = 'utf-8';
            $config['wordwrap'] = TRUE;
            $this->email->initialize($config);
    
            //以下设置Email内容
            $this->email->from('18360@163.com', 'mike');
            $this->email->to($smtp['receiver']);
            $this->email->subject($subject);
            $this->email->message($message);
    
            $result = $this->email->send();
    

      

    单独可以使用的!!!!!

    http://blog.csdn.net/qq_16542775/article/details/47817679

    5.总结

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

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

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

     

  • 相关阅读:
    Linux课程实践一:Linux基础实践(SSH)
    《恶意代码分析实战》读书笔记 静态分析高级技术一
    Linux课程实践四:ELF文件格式分析
    Linux课程实践三:简单程序破解
    Linux课程实践二:编译模块实现内核数据操控
    2020.12.19 加分项和课程意见/建议
    博客已换
    [题解] LuoguP4983 忘情
    [题解] LuoguP4767 [IOI2000]邮局
    [题解] LuoguP2791 幼儿园篮球题
  • 原文地址:https://www.cnblogs.com/norm/p/6248072.html
Copyright © 2011-2022 走看看