【问题标题】:How to I enable establish SMTP connection on Cpanel?如何在 Cpanel 上启用建立 SMTP 连接?
【发布时间】:2019-09-25 10:49:32
【问题描述】:

我希望能够通过 SMTP 从我的应用程序发送电子邮件,并且我不想使用 sendmail 作为传输。

$transport = (new \Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl'))
            ->setUsername('afashaisakiye@gmail.com')
            ->setSourceIp('0.0.0.0')
            ->setPassword('**********');
        //$transport = (new \Swift_SendmailTransport('/usr/sbin/sendmail -bs'));




        // Create the Mailer using your created Transport
        $mailer = new \Swift_Mailer($transport);
        // Create a message
        $message = (new \Swift_Message('This is the message subject'))
            ->setFrom(['afashaisakiye@gmail.com' => 'Smartup Digital team'])
            ->setTo([afasha@linearc.top => 'Isakiye Afasha'])
            ->setBody("thisis an html body", 'text/html', 'iso-8859-2');
        // Send the message
        $result = $mailer->send($message);

这适用于我的计算机,但是当我在 Cpannel 上部署时出现此错误。

Type: Swift_TransportException
Message: Connection could not be established with host smtp.gmail.com [Connection refused #111]
File: /home/linearct/checkin/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php
Line: 269

【问题讨论】:

    标签: smtp cpanel slim swiftmailer


    【解决方案1】:

    默认情况下,您的 CPanel 帐户会禁用外部 SMTP 访问,您必须联系您的服务提供商为您重新启用它。

    【讨论】:

      猜你喜欢
      • 2016-06-01
      • 2021-03-06
      • 2015-11-30
      • 2018-04-17
      • 2017-02-07
      • 2021-10-02
      • 1970-01-01
      • 2012-10-01
      • 1970-01-01
      相关资源
      最近更新 更多