1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.mail.smtp-authentication">
4 <title>SMTP Authentication</title>
7 <classname>Zend_Mail</classname> supports the use of SMTP authentication, which
8 can be enabled be passing the 'auth' parameter to the configuration array in
9 the <classname>Zend_Mail_Transport_Smtp</classname> constructor. The available
10 built-in authentication methods are PLAIN, LOGIN and CRAM-MD5 which all
11 expect a 'username' and 'password' value in the configuration array.
14 <example id="zend.mail.smtp-authentication.example-1">
15 <title>Enabling authentication within Zend_Mail_Transport_Smtp</title>
17 <programlisting language="php"><![CDATA[
18 $config = array('auth' => 'login',
19 'username' => 'myusername',
20 'password' => 'password');
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);
34 <title>Authentication types</title>
37 The authentication type is case-insensitive but has no punctuation.
38 E.g. to use CRAM-MD5 you would pass 'auth' => 'crammd5' in the
39 <classname>Zend_Mail_Transport_Smtp</classname> constructor.