Zend_Mail-SmtpAuthentication.xml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.mail.smtp-authentication">
  4. <title>SMTP Authentication</title>
  5. <para><classname>Zend_Mail</classname> supports the use of SMTP authentication, which
  6. can be enabled be passing the 'auth' parameter to the configuration array in
  7. the <classname>Zend_Mail_Transport_Smtp</classname> constructor. The available
  8. built-in authentication methods are PLAIN, LOGIN and CRAM-MD5 which all
  9. expect a 'username' and 'password' value in the configuration array.</para>
  10. <example id="zend.mail.smtp-authentication.example-1">
  11. <title>Enabling authentication within Zend_Mail_Transport_Smtp</title>
  12. <programlisting language="php"><![CDATA[
  13. $config = array('auth' => 'login',
  14. 'username' => 'myusername',
  15. 'password' => 'password');
  16. $transport = new Zend_Mail_Transport_Smtp('mail.server.com', $config);
  17. $mail = new Zend_Mail();
  18. $mail->setBodyText('This is the text of the mail.');
  19. $mail->setFrom('sender@test.com', 'Some Sender');
  20. $mail->addTo('recipient@test.com', 'Some Recipient');
  21. $mail->setSubject('TestSubject');
  22. $mail->send($transport);
  23. ]]></programlisting>
  24. </example>
  25. <note>
  26. <title>Authentication types</title>
  27. <para>
  28. The authentication type is case-insensitive but has no punctuation.
  29. E.g. to use CRAM-MD5 you would pass 'auth' => 'crammd5' in the
  30. <classname>Zend_Mail_Transport_Smtp</classname> constructor.</para>
  31. </note>
  32. </sect1>
  33. <!--
  34. vim:se ts=4 sw=4 et:
  35. -->