【问题标题】:Getting error while trying to send email in localhost php尝试在 localhost php 中发送电子邮件时出错
【发布时间】:2020-06-25 03:43:06
【问题描述】:

连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者连接的主机没有响应,建立连接失败。

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!');
    }

enter image description here

电子邮件凭据正确。并尝试关闭防火墙但仍然无法正常工作

【问题讨论】:

    标签: php email cakephp localhost phpmailer


    【解决方案1】:

    该错误的含义与它所说的完全相同 - 您尝试连接的服务不存在或没有响应。

    这有两种解释。您连接的服务确实已关闭,或者您尝试连接到错误的服务器或端口。

    在这种情况下,是后者。您正在尝试连接到与该服务无关的端口上的隐式 TLS SMTP 服务。

    改变这个:

    'host' => 'ssl://smtp.gmail.com',
            'port' => 567,
    

    'host' => 'ssl://smtp.gmail.com',
            'port' => 465,
    

    或者

    'host' => 'tls://smtp.gmail.com',
            'port' => 587,
    

    【讨论】:

      猜你喜欢
      • 2017-10-30
      • 2012-08-23
      • 2018-05-16
      • 1970-01-01
      • 2019-01-11
      • 2018-07-26
      • 2021-09-01
      • 1970-01-01
      相关资源
      最近更新 更多