Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, I have used Zend_Mail with SMTP standalone before, here are the files I needed. I also reduced it down to what you need if you only want to use sendmail also.</p> <p>If you want to use Sendmail, that is the easiest. Your dependencies are:</p> <ul> <li>Zend/Exception.php</li> <li>Zend/Mail.php</li> <li>Zend/Mime.php</li> <li>Zend/Mail/Exception.php</li> <li>Zend/Mail/Transport/Abstract.php</li> <li>Zend/Mail/Transport/Exception.php</li> <li>Zend/Mail/Transport/Sendmail.php</li> <li>Zend/Mime/Exception.php</li> <li>Zend/Mime/Message.php</li> <li>Zend/Mime/Part.php</li> </ul> <p>And with those files, here is an example use:</p> <pre><code>&lt;?php // optionally // set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/Zend'); require_once 'Zend/Mail.php'; require_once 'Zend/Mail/Transport/Sendmail.php'; $transport = new Zend_Mail_Transport_Sendmail(); $mail = new Zend_Mail(); $mail-&gt;addTo('user@domain') -&gt;setSubject('Mail Test') -&gt;setBodyText("Hello,\nThis is a Zend Mail message...\n") -&gt;setFrom('sender@domain'); try { $mail-&gt;send($transport); echo "Message sent!&lt;br /&gt;\n"; } catch (Exception $ex) { echo "Failed to send mail! " . $ex-&gt;getMessage() . "&lt;br /&gt;\n"; } </code></pre> <p>If you need SMTP, then you have a few more dependencies to include. In addition to the above you need at least:</p> <ul> <li>Zend/Loader.php</li> <li>Zend/Registry.php</li> <li>Zend/Validate.php</li> <li>Zend/Mail/Protocol/Abstract.php</li> <li>Zend/Mail/Protocol/Smtp.php</li> <li>Zend/Mail/Transport/Smtp.php</li> <li>Zend/Validate/Abstract.php</li> <li>Zend/Validate/Hostname.php</li> <li>Zend/Validate/Interface.php</li> <li>Zend/Validate/Ip.php</li> <li>Zend/Validate/Hostname/*</li> <li>Zend/Mail/Protocol/Smtp/Auth/*</li> </ul> <p>Then you can do something like this:</p> <pre><code>&lt;?php require_once 'Zend/Mail.php'; require_once 'Zend/Mail/Transport/Smtp.php'; $config = array(//'ssl' =&gt; 'tls', 'port' =&gt; '25', //465', 'auth' =&gt; 'login', 'username' =&gt; 'user', 'password' =&gt; 'password'); $transport = new Zend_Mail_Transport_Smtp('smtp.example.com', $config); $mail = new Zend_Mail(); $mail-&gt;addTo('user@domain') -&gt;setSubject('Mail Test') -&gt;setBodyText("Hello,\nThis is a Zend Mail message...\n") -&gt;setFrom('sender@domain'); try { $mail-&gt;send($transport); echo "Message sent!&lt;br /&gt;\n"; } catch (Exception $ex) { echo "Failed to send mail! " . $ex-&gt;getMessage() . "&lt;br /&gt;\n"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload