连接尝试失败是因为被连接方在一段时间后未正确响应,或者建立连接失败是因为连接的主机未响应。
app.php
'EmailTransport' => [
'default' => [
//**'className' => MailTransport::class,
/*
* The following keys are used in SMTP transports:
*/
'host' => 'ssl://smtp.gmail.com',
'port' => 567,
//'timeout' => 30,
'username' => 'abc@gmail.com',
'password' => 'abc',
'className' => 'Smtp',
// 'client' => null,
'tls' => true,
//'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
'Email' => [
'default' => [
'transport' => 'default',
'from' => 'abc@gmail.com',
],
],
控制器类
public function mail()
{
$session = $this->request->session();
$id = $session->read('req_id');
$email = new Email();
$email->transport('default');
$email->from(['NO-REPLY.formcr1@abc.com.au' => 'abc REPLY']);
$email->sender(['NO-REPLY.formcr1@abc.com.au' => 'abc NO-REPLY']);
$email->to('abc@gmail.com'); /** This must be changed to abc's confirmed email */
$email->subject('abc Request Number : '.$id);
//THIS PATH NEEDS TO BE CHANGED DURING DEPLOYMENT
$path = 'C:/xampp/htdocs/request_form/webroot/pdfresults/';
$email->attachments($path. 'abc Cost Estimate Request Information_'.$id.'_'.'v.3online'.'.pdf');
$email->send('Please look for the attachment to see the form. Cheers!');
}
电子邮件凭据正确。并尝试关闭防火墙,但仍然无法工作
答案 0 :(得分:1)
该错误表示它的确切含义-您尝试连接的服务不存在或没有响应。
有两种解释方法。您正在连接的服务确实已关闭,或者您尝试连接到错误的服务器或端口。
在这种情况下,是后者。您正在尝试在与该服务无关的端口上连接到隐式TLS SMTP服务。
更改此:
'host' => 'ssl://smtp.gmail.com',
'port' => 567,
收件人
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
或
'host' => 'tls://smtp.gmail.com',
'port' => 587,