Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter&;PHPMailer_Php_Codeigniter_Email_Smtp_Phpmailer - Fatal编程技术网

Codeigniter&;PHPMailer

Codeigniter&;PHPMailer,php,codeigniter,email,smtp,phpmailer,Php,Codeigniter,Email,Smtp,Phpmailer,所以我已经试了一两天了。起初,我尝试了内置的codeigniter SMTP邮件类,但没有成功。为了解决这个问题,我求助于PHPMailer。令我失望的是,仍然没有运气 我确信所有细节都是正确的。我甚至尝试了多个SMTP服务器,其中包括gmail和mandrill 下面是我正在使用的代码(我已经尝试了许多不同的修改版本,但我会给你一个我目前正在使用的版本) 如果需要,你可以 我刚刚收到错误2014-06-09 11:18:40 SMTP错误:无法连接到服务器:连接超时(110)SMTP co

所以我已经试了一两天了。起初,我尝试了内置的codeigniter SMTP邮件类,但没有成功。为了解决这个问题,我求助于PHPMailer。令我失望的是,仍然没有运气

我确信所有细节都是正确的。我甚至尝试了多个SMTP服务器,其中包括gmail和mandrill

下面是我正在使用的代码(我已经尝试了许多不同的修改版本,但我会给你一个我目前正在使用的版本)


如果需要,你可以


我刚刚收到错误
2014-06-09 11:18:40 SMTP错误:无法连接到服务器:连接超时(110)SMTP connect()失败。无法发送邮件。邮件程序错误:SMTP connect()失败。

由于Codeigniter具有电子邮件帮助程序,您不需要使用其他复杂方式。您只需加载助手并使用以下结构发送邮件

     $name="some name";
     $message="your text message";
     // set email data
     $this->load->library('email');
     $this->email->set_mailtype("html");
     $this->email->from($this->input->post('sender_email'), $name);
     $this->email->to('destination_email');
     $this->email->cc('alternative_email');
     $this->email->subject('Enquiry');
     $this->email->message($message);
     $this->email->send();
试试这个:

$this->load->library('email');

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.mandrillapp.com';
$config['smtp_user'] = 'email@outlook.com';
$config['smtp_pass'] = 'password4mandrill';
$config['smtp_port'] = 587;

$this->email->initialize($config);

$this->email->from('you@outlook.com');
$this->email->to('dest@mail.com');
$this->email->subject('Test');
$this->email->message('Message');

if($this->email->send()) {
    echo 'Sent';
} else {
    $this->email->print_debugger();
}

选项的完整列表:

您遇到的问题级别低于您的脚本。SMTP连接失败意味着它甚至无法开始与服务器通信,因此它与身份验证或您如何构造邮件无关-所有这些都与调用mail()或在某个点直接与SMTP通信无关,并遇到相同的问题,如您所见


最可能的解释是您的DNS不工作。接下来,我将研究防火墙问题,然后确保php环境中未禁用
fsockopen
stream\u socket\u client
函数。

请删除smtp用户名和密码OK,这样错误是无法连接到smtp服务器。可能smtp验证错误,或者尝试使用配置文件。我知道它们没有连接。正如我所说,我已经尝试了许多不同的代码和不同的smtp服务器,我确信我输入的详细信息是正确的。如果这是你正在使用的代码,那么为什么你问题底部的链接试图连接到gmail端口465?这将是SSL而不是TLS端口!从您发布的内容来看,超时很可能是错误的端口设置->但无法查看您是否犯了小错误,因为您发布的代码本身看起来很好。谢谢您的回复!实际端口在代码发布之前已更改,所有信息都已更改。虽然,我也尝试过Gmail,但还是没有运气。嗨,谢谢你的回复。正如我在前面的声明中提到的,我已经尝试使用CodeIgniter默认邮件类,但是也没有成功。
$this->load->library('email');

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.mandrillapp.com';
$config['smtp_user'] = 'email@outlook.com';
$config['smtp_pass'] = 'password4mandrill';
$config['smtp_port'] = 587;

$this->email->initialize($config);

$this->email->from('you@outlook.com');
$this->email->to('dest@mail.com');
$this->email->subject('Test');
$this->email->message('Message');

if($this->email->send()) {
    echo 'Sent';
} else {
    $this->email->print_debugger();
}