【问题标题】:mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()mail():无法在“localhost”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用 ini_set()
【发布时间】:2018-08-03 10:50:53
【问题描述】:

我目前正在使用 codeigniter 发送邮件,下面是 smtp 的详细信息,但我收到错误如何解决这个问题 stackoverflow 上的一些帖子要求在 php.ini 中进行一些修改仍然遇到同样的问题。

$config = Array(//for gmail Settings 
                    'protocol' => 'smtp',
                    'smtp_host' => 'ssl://smtp.gmail.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'xyz@gmail.com', // user details
                    'smtp_pass' => 'xyzxyz', // password
                    'mailtype' => 'html',
                    'charset' => 'iso-8859-1',
                    'wordwrap' => TRUE
                );




               $this->load->library('email', $config);
                $this->email->set_header('MIME-Version', '1.0; charset=utf-8');
                $this->email->set_header('Content-type', 'text/html');
                $this->email->set_newline("\r\n");
                 $this->email->from('xyz@gmail.com@gmail.com', 'xyz.com'); //sender's email

                $this->email->to($email); // change it to yours
                $this->email->subject('Password reset email');
                $message = "<h2>You have requested to reset password</h2>";
                $message .= "<a href='" . base_url('controller') . "/" . "methodname/" . $reset . "'> Click here to reset your password</a>";
                $this->email->message($message);
                $send = $this->email->send();

【问题讨论】:

  • 您在 php.ini 中做了哪些更改
  • 似乎电子邮件库未使用提供的配置初始化,并且正在使用来自/application/config/email.php 文件的配置

标签: php codeigniter email smtp


【解决方案1】:

这个配置帮助我解决了我的问题

$config = array(
                    'protocol' => 'smtp',
                    'smtp_host' => 'smtp.gmail.com',
                    'smtp_port' => 465,
                    'smtp_crypto' => 'ssl',
                    'smtp_timeout' => '30',
                    'smtp_user' => 'xyz@gmail.com', //  your smtp user
                    'smtp_pass' => 'xyzxyz', //  your smtp password
                    'wordwrap' => TRUE
                );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-14
    • 2011-06-03
    • 2017-02-04
    • 2012-08-02
    • 1970-01-01
    • 2011-01-21
    • 2021-12-24
    相关资源
    最近更新 更多