php - 无法使用 PHP SMTP 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件

标签 php codeigniter email

我正在使用 codeigniter

我在实时服务器上执行了代码。 使用 print_debugger() 出现以下错误

Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

public function sendEnquiry() {
            $this->load->library('email');
            $name = $this->input->post("fname");
            $cemail = $this->input->post("email");
            $pno = $this->input->post("phone");
            $message = $this->input->post("message");
            $config['protocol']    = 'smtp';
            $config['smtp_host']    = 'ssl://mail.gatewaykhobar.com';
            $config['smtp_port']    = '465';
            $config['smtp_timeout'] = '7';
            $config['smtp_user']    = '***********';
            $config['smtp_pass']    = '***********';
            $config['charset']    = 'utf-8';
            $config['newline']    = "\r\n";
            $config['mailtype'] = 'text'; // or html
            $config['validation'] = FALSE;

            $this->email->initialize($config);
            $this->email->from('info@gatewaykhobar.com','Gateway Restaurent Contact');
            $this->email->to($cemail); 
            $this->email->subject('Gateway Restaurent Contact Enquiry');

           $this->email->message($message);  
            $send = $this->email->send();
            if($send) {
                echo json_encode("send");
            } else {
                $error = $this->email->print_debugger(array('headers'));
                echo json_encode($error);
            }

        }

最佳答案

smtp_port 从 465 更改为 587。

确保 $config['newline'] = "\r\n"; 是双引号而不是单引号。

关于php - 无法使用 PHP SMTP 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45252547/

相关文章:

php - 基于重叠实体数组创建新数组

php - 如何使生成的代码在输入几次后过期(PHP)?

php - 使用 CI 更新两个表中的内容

ruby-on-rails - 如何发送群发邮件而不以垃圾邮件告终的原则

php - 从本地电脑的 outlook php 读取电子邮件

android - 仅使用 Android 中的电子邮件客户端应用程序发送电子邮件

PHP MySQL : INET_ATON does not save data?

php - 复制特定键的有效方法

php - 如果没有找到所有数据,Mysql 查询返回 false

php - 使用 Phing 和 SVN 的生产和开发环境