|
我们做了一个项目,其中需要用户邮箱验证,可是我每次在本机测试就是对的,上传服务器后就不对了,服务器上是Linux+Apache+MySQL+php环境,本机是Windows7+xampp环境,源代码如下:
PHP复制代码
function send_email($email, $subject, $content) {
$config['protocol'] = 'smtp';//邮件发送协议
$config['smtp_host'] = 'smtp.126.com';//SMTP 服务器地址
$config['smtp_user'] = '';//SMTP 用户账号,我用的是126邮箱,帐号是有的,在这里不提供,我想应该不是这的问题,因为本地测试是可以的
$config['smtp_pass'] = '';//SMTP 密码,密码也是正确的,本地测试同样能通过
$this->email->initialize($config);//设置 Email 参数
$this->email->clear();//将所有EMAIL的变量清空
$this->email->from('cuit_daydayup@126.com', 'daydayup项目组');//设置发件人email地址和名称
$this->email->to($email);//设置收件人email地址
$this->email->subject($subject);//设置email主题
$this->email->message($content);//设置email正文部分
if ($this->email->send()) {//发送邮件并判断是否发送成功
return TRUE;
}else {
return FALSE;
}
}
复制代码
其中$email为目的邮箱参数, $subject为邮件主题参数,$content为邮件内容参数,都是由调用该函数的函数传入,但是从来没有成功发出去过邮件,报错内容如下:
A PHP Error was encounteredSeverity: Warning
Message: fsockopen(): unable to connect to smtp.126.com:25 (Permission denied)
Filename: libraries/Email.php
Line Number: 1689
A PHP Error was encounteredSeverity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encounteredSeverity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encounteredSeverity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encounteredSeverity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encounteredSeverity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encounteredSeverity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encounteredSeverity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encounteredSeverity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encounteredSeverity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encounteredSeverity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encounteredSeverity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
我在网上找了,说是Apache默认不支持邮件发送功能,我改了php.ini中的配置,将SMTP后面的内容给为“smtp.126.com”,然后将sendmail_from后面的内容,改成和上面用来发送邮件的地址一样了,可是依然报上面的错误,求高手指点,我是应该修改代码,还是应该修改服务器配置?
另外,我的服务器是打在Windows 7上的虚拟机,用的centOS ,求高手指点
|
|