Zend_Mail-Sending.xml 1.4 KB

12345678910111213141516171819202122232425262728
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.mail.sending">
  4. <title>Sending via SMTP</title>
  5. <para>
  6. To send mail via SMTP, <classname>Zend_Mail_Transport_Smtp</classname> needs to be created and registered with
  7. <classname>Zend_Mail</classname> before the <code>send()</code> method is called. For all remaining
  8. <classname>Zend_Mail::send()</classname> calls in the current script, the SMTP transport will then be used:
  9. </para>
  10. <example id="zend.mail.sending.example-1">
  11. <title>Sending E-Mail via SMTP</title>
  12. <programlisting language="php"><![CDATA[
  13. $tr = new Zend_Mail_Transport_Smtp('mail.example.com');
  14. Zend_Mail::setDefaultTransport($tr);
  15. ]]></programlisting>
  16. </example>
  17. <para>
  18. The <code>setDefaultTransport()</code> method and the constructor of
  19. <classname>Zend_Mail_Transport_Smtp</classname> are not expensive. These two lines can be processed at script
  20. setup time (e.g., config.inc or similar) to configure the behavior of the <classname>Zend_Mail</classname> class
  21. for the rest of the script. This keeps configuration information out of the application logic - whether
  22. mail is sent via SMTP or <ulink url="http://php.net/mail"><code>mail()</code></ulink>, what mail server
  23. is used, etc.
  24. </para>
  25. </sect1>
  26. <!--
  27. vim:se ts=4 sw=4 et:
  28. -->