PHP - Swiftmailer using STARTTLS and self signed certificates

前端 未结 4 528
眼角桃花
眼角桃花 2020-12-05 11:32

I\'m trying to send an email with php and swiftmailer, using STARTTLS, but I\'m getting a certificate error. I have root access to the SMTP server, and the certificate used

4条回答
  •  余生分开走
    2020-12-05 11:50

    Swiftmailer has now been updated to include an option for this. It can now be solved using the setStreamOptions method from your Swift_SmtpTransport instance rather than editing the swift class.

    $transport = Swift_SmtpTransport::newInstance('smtp.server.com', 123, 'tls')
        ->setUsername('username')
        ->setPassword('password')
        ->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));
    

提交回复
热议问题