1

this is a follow up question from this

In PHP 5.6, 'verify_peer' and 'verify_peer_name' by default are set to true and this is causing connectivity issues with gmail for me.

A fix was implemented here which lets you setStreamOptions of an EsmtpTransport allowing you to disable these checks. This is fine, however I am spooling emails on symfony and the transporter used when spooling is SpoolTransport which does not allow you to setStreamOptions.

I could could disable the SSL check by modifying the function "_establishSocketConnection" in StreamBuffer.php and adding these lines before stream_socket_client command:

$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;

However that is a dirty fix and involves changing vendor code.

Is there any other option to disable these checks when spooling? My swifmailer config is below for reference

# Swiftmailer Configuration
swiftmailer:
    transport:  smtp
    host:       smtp.gmail.com
    username:   XXX
    password:   XXX
    port:       465
    encryption: ssl
    spool:
        type: file
        path: '%kernel.root_dir%/spool'
user972616
  • 1,324
  • 3
  • 18
  • 38

1 Answers1

2

Get the transport object and call this:

$transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));

In Symfony, probably something like this: $transport = $this->get("swiftmailer.mailer.default.transport");

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39