用户
 找回密码
 入住 CI 中国社区
搜索
查看: 6368|回复: 3
收起左侧

[其它 Other] 使用email类,发送SMTP邮件,己测试过

[复制链接]
发表于 2009-7-15 17:12:49 | 显示全部楼层 |阅读模式
本帖最后由 lichaoying 于 2009-7-15 17:21 编辑

包括以下内容,都是论坛里大家问的问题,或许对大家有用:
1、附件发送
2、解决乱码问题
3、发送结果验证
PHP复制代码
function sendmail(){
       $config = Array(
             'protocol' => 'smtp',
              'smtp_host' => 'mail.cmcc.cn',
              'smtp_port' => 25,
             'smtp_user' => 'lichao',
                 'smtp_pass' => '123',
                  'charset' => 'gb2312',
             'mailtype' => 'html',
         );
     //SSL的方法
      // $config_ssl = Array(
          // 'protocol' => 'smtp',
          //  'smtp_host' => 'ssl://smtp.gmail.com',
          //  'smtp_port' => '465',
          // 'smtp_user' => '123@gmail.com',
          //  'smtp_pass' => '123',
          //  'mailtype' => 'html',
     //    );
        $this->load->library('email', $config);
        $this->email->set_newline("rn");
        $from_name = "小李";//发件人名称
        $email_subject ="调单";
        $email_msg="<br>你好!请注意查收!";
        //解决乱码问题
        $from_name = iconv('UTF-8','GB2312',$from_name);
        $email_subject = iconv('UTF-8','GB2312',$email_subject);
        $email_msg = iconv('UTF-8','GB2312',$email_msg);
        //封装发送信息
        $this->email->from('lichao@chinamobile.com',$from_name);
        $this->email->to('lichao@chinamobile.com');
        $this->email->subject($email_subject);
        $this->email->message($email_msg);
        $this->email->attach("attachments/2009/01/1.xls");//附件
        //发送
       if (!$this->email->send())
        {
            show_error($this->email->print_debugger());
            return false;
        }
        else
        {
            echo"发送成功!";
            return true;
        }
   }
复制代码

源码.rar

721 Bytes, 下载次数: 208

评分

参与人数 1威望 +5 收起 理由
Hex + 5 我很赞同

查看全部评分

发表于 2009-8-19 16:00:02 | 显示全部楼层
请问下你的smtp是怎么配置
发表于 2012-2-28 16:09:21 | 显示全部楼层
请问楼主:你的smtp是怎么配置的啊?你试过用QQ邮箱发送没有?
发表于 2012-8-20 15:58:58 | 显示全部楼层
怎么设置发送html

本版积分规则