Zend_Mail-Sending.xml 1.4 KB

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