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

[HELP] CI发送邮件失败!

[复制链接]
发表于 2011-10-11 14:44:49 | 显示全部楼层 |阅读模式
5CI币
代码如下
在控制器内:
$this->load->library ( 'email' );
$this->email->from ( SMTP_USER, USER_NAME );
$this->email->to ( $toList );
$this->email->subject ( MAIL_TITLE );
$this->email->message ( $mailContent );

在config/email.php内:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//SMTP 端口
$config ['smtp_port'] = 25;
//邮件发送协议
$config ['protocol'] = SMTP_PROC;
// STMP服务主机地址
$config ['smtp_host'] = SMTP_HOST;
// STMP邮箱地址
$config ['smtp_user'] = SMTP_USER;
// STMP邮箱密码
$config ['smtp_pass'] = SMTP_PASS;

为什么到此发送邮件失败?但是为什么加上如下两行:
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
就能成功呢?(我开发用的win7系统)
此外,如果想在linux服务器上发邮件能否成功呢?如果不能又该如何改动呢?
在线等待各位高手指导,不胜感激!

发表于 2011-10-11 15:42:27 | 显示全部楼层
大哥。你的常量 SMTP_定义但是那里赋值。 echo $this->email->print_debugger ();看一下神马情况
小列
控制器
PHP复制代码
 
public function index() {
                 
                 $this->load->library ( 'email' );
                $this->email->from ( '****************@163.com', 'Your Name' );
                $this->email->to ( '****************@qq.com' );
                $this->email->subject ( 'Email Test' );
                $this->email->message ( 'Testing the email class.' );
                $this->email->send ();
                echo $this->email->print_debugger ();
        }
 
 
复制代码


config里的email.php
PHP复制代码
 
<?php
if (! defined ( 'BASEPATH' ))
        exit ( 'No direct script access allowed' );
       
 
$config ['mailtype'] = 'html';
$config ['charset'] = 'utf-8';
$config ['newline'] = '\r\n';
 
$config ['protocol'] = 'smtp';
$config ['smtp_host'] = 'smtp.163.com';
$config ['smtp_user'] = '************@163.com';
$config ['smtp_pass'] = '***************';
$config ['mailtype'] = 'html';
$config ['validate'] = true;
$config ['priority'] = 1;
$config ['crlf'] = "\r\n";
$config ['smtp_port'] = 25;
$config ['charset'] = 'utf-8';
$config ['wordwrap'] = TRUE;
 
 
复制代码


回复

使用道具 举报

 楼主| 发表于 2011-10-11 15:59:52 | 显示全部楼层
斯达客 发表于 2011-10-11 15:42
大哥。你的常量 SMTP_定义但是那里赋值。 echo $this->email->print_debugger ();看一下神马情况
小列
控 ...

那个定义没有问题
因为我加上
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
这两行时发送成功了,去掉的话就出现下面的问题:

220 ******************************

hello: 250-XFORWARD NAME ADDR PROTO HELO SOURCE
250-XXXXXXA
250-SIZE 47185920
250-ETRN
250-AUTH LOGIN
250-AUTH=LOGIN
250 8BITMIME

Failed to authenticate username. Error: 500 Error: bad syntax

from:

The following SMTP error was encountered:

to:

The following SMTP error was encountered:

to:

The following SMTP error was encountered:

data:

The following SMTP error was encountered:

The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
回复

使用道具 举报

发表于 2011-10-11 16:23:15 | 显示全部楼层
回复

使用道具 举报

发表于 2011-10-11 16:40:02 | 显示全部楼层
你的邮箱(发信人)是否开通了POP3服务。请到邮箱设置里进行查看。
回复

使用道具 举报

发表于 2011-10-11 16:51:35 | 显示全部楼层
很久以前做过 是因为pop3服务问题 换个邮箱后来就好啦!!!
回复

使用道具 举报

本版积分规则