Zend_Mail-Sending.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <sect1 id="zend.mail.sending">
  2. <title>
  3. Отправка через SMTP
  4. <!--
  5. Sending via SMTP
  6. -->
  7. </title>
  8. <para>
  9. Чтобы отправить сообщение электронной почты через SMTP,
  10. нужно создать и зарегистрировать объект <code>Zend_Mail_Transport_Smtp</code>,
  11. прежде чем будет вызван метод <code>send()</code>. Для всех последующих
  12. вызовов <code>Zend_Mail::send()</code> в текущем скрипте будет
  13. использоваться SMTP:
  14. <!--
  15. To send mail via SMTP, <code>Zend_Mail_Transport_Smtp</code> needs to be created and registered with
  16. <code>Zend_Mail</code> before the <code>send()</code> method is called. For all remaining
  17. <code>Zend_Mail::send()</code> calls in the current script, the SMTP transport will then be used:
  18. -->
  19. </para>
  20. <example>
  21. <title>
  22. Отправка сообщений через SMTP
  23. <!--
  24. Sending E-Mail via SMTP
  25. -->
  26. </title>
  27. <programlisting language="php"><![CDATA[<?php
  28. require_once 'Zend/Mail/Transport/Smtp.php';
  29. $tr = new Zend_Mail_Transport_Smtp('mail.example.com');
  30. Zend_Mail::setDefaultTransport($tr);
  31. ?>]]> </programlisting>
  32. </example>
  33. <para>
  34. Метод <code>setDefaultTransport()</code> и конструктор
  35. <code>Zend_Mail_Transport_Smtp</code> не являются ресурсоемкими. Эти две
  36. строки кода могут быть выполнены во время подготовки (т.е. в файле config.inc
  37. или подобном), чтобы сконфигурировать поведение класса <code>Zend_Mail</code>
  38. для остальной части скрипта. Это позволит держать конфигурационные данные
  39. отдельно от логики приложения — отправляется ли почта через SMTP или
  40. <ulink url="http://php.net/mail"><code>mail()</code></ulink>,
  41. какой почтовый сервер используется и т.д.
  42. <!--
  43. The <code>setDefaultTransport()</code> method and the constructor of
  44. <code>Zend_Mail_Transport_Smtp</code> are not expensive. These two lines can be processed at script
  45. setup time (e.g., config.inc or similar) to configure the behaviour of the <code>Zend_Mail</code> class
  46. for the rest of the script. This keeps configuration information out of the application logic - whether
  47. mail is sent via SMTP or <ulink url="http://php.net/mail"><code>mail()</code></ulink>, what mail server
  48. to use, etc.
  49. -->
  50. </para>
  51. </sect1>
  52. <!--
  53. vim:se ts=4 sw=4 et:
  54. -->