1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.mail.smtp-secure">
4 <title>Securing SMTP Transport</title>
7 <classname>Zend_Mail</classname> also supports the use of either TLS or
8 <acronym>SSL</acronym> to secure a SMTP connection. This can be enabled be passing the
9 'ssl' parameter to the configuration array in the
10 <classname>Zend_Mail_Transport_Smtp</classname> constructor with a value of either 'ssl' or
11 'tls'. A port can optionally be supplied, otherwise it defaults to 25 for TLS or 465 for
12 <acronym>SSL</acronym>.
15 <example id="zend.mail.smtp-secure.example-1">
16 <title>Enabling a secure connection within Zend_Mail_Transport_Smtp</title>
18 <programlisting language="php"><![CDATA[
19 $config = array('ssl' => 'tls',
20 'port' => 25); // Optional port number supplied
22 $transport = new Zend_Mail_Transport_Smtp('mail.server.com', $config);
24 $mail = new Zend_Mail();
25 $mail->setBodyText('This is the text of the mail.');
26 $mail->setFrom('sender@test.com', 'Some Sender');
27 $mail->addTo('recipient@test.com', 'Some Recipient');
28 $mail->setSubject('TestSubject');
29 $mail->send($transport);