How can the "self signed certificate" notice be suppressed when connecting to a mail server in PHP without using error_reporting()?

When connecting to a mail server in PHP, the "self signed certificate" notice can be suppressed by setting the 'ssl' context option to verify_peer to false. This will disable peer verification and prevent the notice from being displayed.

$transport = (new Swift_SmtpTransport('mail.example.com', 587, 'tls'))
  ->setUsername('your_username')
  ->setPassword('your_password')
  ->setStreamOptions(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false]]);