Securing SMTP Transport - Zend_Mail

Securing SMTP Transport

Zend_Mail also supports the use of either TLS or SSL to secure a SMTP connection. This can be enabled be passing the 'ssl' parameter to the configuration array in the Zend_Mail_Transport_Smtp constructor with a value of either 'ssl' or 'tls'. A port can optionally be supplied, otherwise it defaults to 25 for TLS or 465 for SSL.

Example #1 Enabling a secure connection within Zend_Mail_Transport_Smtp

  1. $config = array('ssl' => 'tls',
  2.                 'port' => 25); // Optional port number supplied
  4. $transport = new Zend_Mail_Transport_Smtp('', $config);
  6. $mail = new Zend_Mail();
  7. $mail->setBodyText('This is the text of the mail.');
  8. $mail->setFrom('', 'Some Sender');
  9. $mail->addTo('', 'Some Recipient');
  10. $mail->setSubject('TestSubject');
  11. $mail->send($transport);


© 2006-2022 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.