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