使用SMTP协议发送邮件CodeIgniter不起作用 [英] Sending mail with CodeIgniter using SMTP protocol not working

查看:199
本文介绍了使用SMTP协议发送邮件CodeIgniter不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CI发送邮件时遇到问题。我使用sendmail协议发送邮件,但它被过滤为垃圾邮件。我使用了SMTP协议来解决这个问题,但并没有发送。



我的代码如下:

  $ config = Array(
'protocol'=>'smtp',
'smtp_host'=>'ssl://smtp.googlemail.com ',
'smtp_port'=> 465,
'smtp_user'=>'*******@gmail.com',
'smtp_pass'=>'* *******',
'mailtype'=>'html',
'charset'=>'iso-8859-1'
);

$ this-> load->库('email',$ config);
$ this-> email-> set_newline(\r\\\
);
$ message =test mail;
$ this-> email-> set_newline(\r\\\
);
$ this-> email-> from('dsiddharth2@gmail.com','St. Maries');
$ this-> email->至(dsiddharth2@gmail.com);
$ this-> email->主题('Contact - St. Marians Belguam');
$ this->电子邮件>消息($ message);
if($ this-> email-> send())
{
echo邮件发送成功;
}
else
{
show_error($ this-> email-> print_debugger());
}

当我在CI中使用smtp协议发送邮件时,以下错误:

 遇到PHP错误

严重性:警告

消息:fsockopen()[function.fsockopen]:无法连接到ssl://smtp.googlemail.com:465(连接超时)

文件名:libraries / Email.php

行号:1673

以及其他错误列表...



我要求服务器管理员启用openssl。它已经被照顾并被启用。



如果您想尝试一下,请访问此链接并检查自己。 解决方案

,检查你的php.ini文件。更改此行



; extension = php_openssl.dll



改为



extension = php_openssl.dll



这意味着从php中删除注释。 ini文件。


I have a problem in sending mails using CI. I used the "sendmail" protocol to send mail but it is being filtered as spam. I used the SMTP protocol to solve the problem, but it's not getting sent.

My code is as follows:

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => '*******@gmail.com',
    'smtp_pass' => '********',
    'mailtype'  => 'html',
    'charset'   => 'iso-8859-1'
);

$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$message = "test mail";
$this->email->set_newline("\r\n");
$this->email->from('dsiddharth2@gmail.com', 'St. Maries');
$this->email->to("dsiddharth2@gmail.com");
$this->email->subject('Contact - St. Marians Belguam');
$this->email->message($message);
if($this->email->send())
{
    echo "mail sent successfully";
}
else
{
    show_error($this->email->print_debugger());
}

When I send the email using "smtp" protocol in CI, I get the following error:

A PHP Error was encountered

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)

Filename: libraries/Email.php

Line Number: 1673

and other list of errors...

I asked the server admin to enable the "openssl". It's been already taken care of and is enabled.

If you want to try it out, please visit this link and check for yourself.

解决方案

If it's not working, check your php.ini file. Change this line

;extension=php_openssl.dll

to

extension=php_openssl.dll

It means remove the comment from the line in php.ini file.

这篇关于使用SMTP协议发送邮件CodeIgniter不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆