邮件发送不成功
请问大神们,我想发送一下邮件,怎么都请求超时,具体代码如下:public function use_email(){
$this->load->library('email');
$config['protocol']='smtp';
//$config['protocol']='sendmail';
$config['smtp_host']='smtp.qq.com';
$config['mailpath']='E:/tools/php5/sendmail';
$config['smtp_user']='7800*****@qq.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;
$this->email->initialize($config);
$this->email->from('7800****@qq.com','suzhisheng');
$this->email->to('404317***@qq.com');
$this->email->subject("Email Test");
$this->email->message('Testing the email class');
$this->email->send();
echo $this->email->print_debugger();
}
结果如下:
Fatal error: Maximum execution time of 300 seconds exceeded in E:\tools\apache\htdocs\CIlearn\system\libraries\Email.php on line1869
//我的代码你看一下 是成功的
public function email(){
$this->load->library('Email');
//以下设置Email参数
$config ['mailtype'] = 'html';
$config ['charset'] = 'utf-8';
$config ['newline'] = '\r\n';
$config ['protocol'] = 'smtp';
$config ['smtp_host'] = 'smtp.163.com'; //163SMTP服务器地址
$config ['smtp_user'] = 'xc_lemon@163.com'; //邮箱地址
$config ['smtp_pass'] = 'qtmlzameaghefrsq'; //客户端授权码(手机短信)
$config ['mailtype'] = 'html'; //邮件类型
$config ['validate'] = true; //是否验证邮箱地址
$config ['priority'] = 1; //Email 优先级. 1 = 最高. 5 = 最低. 3 = 正常.
$config ['crlf'] = "\r\n"; //换行符
$config ['smtp_port'] = 25; //SMTP端口
$config ['charset'] = 'utf-8'; //gb2312会出现乱码
$config ['wordwrap'] = TRUE; //开启自动换行
$this->email->initialize($config);
//以下设置Email内容
$this->email->from('xc_lemon@163.com', 'xc_lemon'); //发件人email地址和名称
$this->email->to('1327503612@qq.com,xuchen@daoke.me'); //收件人的Email地址
$this->email->subject('Email Test'); //主题
$this->email->message('<font color=blue>哈哈哈哈哈哈哈哈哈哈哈哈</font>');//内容
//相对于index.php的路径
$this->email->attach('uploads/1_thumb.jpg'); //图片
$this->email->send();
echo $this->email->print_debugger();
} suzhisheng 发表于 2015-6-16 09:31
恩还是不行,The following SMTP error was encountered: 0 Unable to find the socket transport "ssl"...
这是我的邮件测试代码,你对照修改一下相关参数,我这里测试没问题(PHP5.5.20, CI3.0,QQ企业邮箱)
$post_array = $this->input->post();
// 配置项
$config = array(
'protocol' => 'smtp',
'smtp_host' => trim($post_array['email_host']),
'smtp_user' => trim($post_array['email_id']),
'smtp_pass' => trim($post_array['email_pass']),
'smtp_port' => trim($post_array['email_port']),
'smtp_timeout' => '5',
'charset' => 'utf-8',
'mailtype' => 'text'
);
// 加载类库
$this->load->library('email', $config);
// 邮件
$this->email->from(trim($post_array['email_addr']), 'From email name');
$this->email->to(trim($post_array['email_test']));
$this->email->subject($this->lang->line('test_email'));
$this->email->message('test email!!');
// 发送
if($this->email->send())
{
// 成功信息
}
else
{
// 错误信息
}
pcjingl 发表于 2015-6-17 17:35
php.ini 中,将 extension=php_openssl.dll 前面的注释符号“;”去掉。重启apache
开启啦,现在还是不行
The following SMTP error was encountered: 10060 �������ӷ���һ��ʱ����û����ȷ� QQ企业邮箱的地址应该是:ssl://smtp.exmail.qq.com, 详细信息请看http://service.exmail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1000585
我的设置是这样的,发送邮件没有问题。
http://codeigniter.org.cn/forums/data/attachment/album/201506/16/000438h4dmjd0wr43nfddw.png
pcjingl 发表于 2015-6-16 00:05
QQ企业邮箱的地址应该是:ssl://smtp.exmail.qq.com, 详细信息请看http://service.exmail.qq.com/cgi-bin/h ...
恩还是不行,The following SMTP error was encountered: 0 Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:<7800*****@qq.com>
from:
那段英文错误的意思不是说要你PHP支持SSL么? ahcheqiu 发表于 2015-6-16 16:31
那段英文错误的意思不是说要你PHP支持SSL么?
你是说要开启什么服务或者开启什么扩展吗
suzhisheng 发表于 2015-6-17 09:33
你是说要开启什么服务或者开启什么扩展吗
也有可能是只需要修改php的配置,你把那段错误百度了一下么
php.ini 中,将 extension=php_openssl.dll 前面的注释符号“;”去掉。重启apache ahcheqiu 发表于 2015-6-17 12:30
也有可能是只需要修改php的配置,你把那段错误百度了一下么
恩,那些什么服务我都开启了,不过后来我发现我的phpinfo()里面居然没有php_openssl.这个服务,所以今天折腾了一天,重新搭建了一下环境
页:
[1]
2