| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <sect1 id="zend.mail.sending">
- <title>
- Отправка через SMTP
- <!--
- Sending via SMTP
- -->
- </title>
- <para>
- Чтобы отправить сообщение электронной почты через SMTP,
- нужно создать и зарегистрировать объект <code>Zend_Mail_Transport_Smtp</code>,
- прежде чем будет вызван метод <code>send()</code>. Для всех последующих
- вызовов <code>Zend_Mail::send()</code> в текущем скрипте будет
- использоваться SMTP:
- <!--
- To send mail via SMTP, <code>Zend_Mail_Transport_Smtp</code> needs to be created and registered with
- <code>Zend_Mail</code> before the <code>send()</code> method is called. For all remaining
- <code>Zend_Mail::send()</code> calls in the current script, the SMTP transport will then be used:
- -->
- </para>
- <example>
- <title>
- Отправка сообщений через SMTP
- <!--
- Sending E-Mail via SMTP
- -->
- </title>
- <programlisting language="php"><![CDATA[<?php
- require_once 'Zend/Mail/Transport/Smtp.php';
- $tr = new Zend_Mail_Transport_Smtp('mail.example.com');
- Zend_Mail::setDefaultTransport($tr);
- ?>]]> </programlisting>
- </example>
- <para>
- Метод <code>setDefaultTransport()</code> и конструктор
- <code>Zend_Mail_Transport_Smtp</code> не являются ресурсоемкими. Эти две
- строки кода могут быть выполнены во время подготовки (т.е. в файле config.inc
- или подобном), чтобы сконфигурировать поведение класса <code>Zend_Mail</code>
- для остальной части скрипта. Это позволит держать конфигурационные данные
- отдельно от логики приложения — отправляется ли почта через SMTP или
- <ulink url="http://php.net/mail"><code>mail()</code></ulink>,
- какой почтовый сервер используется и т.д.
- <!--
- The <code>setDefaultTransport()</code> method and the constructor of
- <code>Zend_Mail_Transport_Smtp</code> are not expensive. These two lines can be processed at script
- setup time (e.g., config.inc or similar) to configure the behaviour of the <code>Zend_Mail</code> class
- for the rest of the script. This keeps configuration information out of the application logic - whether
- mail is sent via SMTP or <ulink url="http://php.net/mail"><code>mail()</code></ulink>, what mail server
- to use, etc.
- -->
- </para>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|