Zend_Mail-SmtpAuthentication.xml 1.6 KB

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