Minimize Zend Framework for Zend_Mail?

Possible duplicate:
Use Zend Framework components without a real structure?

I just need the Zend_Mail features for the Zend Framework, but the whole structure is about 300 MB. Is there a way to reduce it to basic and Zend_Mail to save disk space?

+4
source share
2 answers

Yes, I used to use Zend_Mail with stand-alone SMTP, here are the files I need. I also reduced it to what you need if you also want to use sendmail.

If you want to use Sendmail, this is the easiest. Your dependencies:

  • Zend / Exception.php
  • Zend / Mail.php
  • Zend / mime.php
  • Zend / Mail / Exception.php
  • Zend / Mail / Transport / Abstract.php
  • Zend / Mail / Transport / Exception.php
  • Zend / Mail / Transport / Sendmail.php
  • Zend / Mime / Exception.php
  • Zend / mime / message.php
  • Zend / Mime / Part.php

And with these files, here is a usage example:

<?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->addTo(' user@domain ') ->setSubject('Mail Test') ->setBodyText("Hello,\nThis is a Zend Mail message...\n") ->setFrom(' sender@domain '); try { $mail->send($transport); echo "Message sent!<br />\n"; } catch (Exception $ex) { echo "Failed to send mail! " . $ex->getMessage() . "<br />\n"; } 

If you need SMTP, you have a few more dependencies to enable. In addition to the above, you need at least:

  • Zend / loader.php
  • Zend / registry.php
  • Zend / Validate.php
  • Zend / Mail / Protocol / Abstract.php
  • Zend / Mail / Protocol / Smtp.php
  • Zend / Mail / Transport / Smtp.php
  • Zend / Validate / Abstract.php
  • Zend / Validate / Hostname.php
  • Zend / Validate / Interface.php
  • Zend / Validate / Ip.php
  • Zend / Validate / Hostname / *
  • Zend / Mail / Protocol / Smtp / Auth / *

Then you can do something like this:

 <?php require_once 'Zend/Mail.php'; require_once 'Zend/Mail/Transport/Smtp.php'; $config = array(//'ssl' => 'tls', 'port' => '25', //465', 'auth' => 'login', 'username' => 'user', 'password' => 'password'); $transport = new Zend_Mail_Transport_Smtp('smtp.example.com', $config); $mail = new Zend_Mail(); $mail->addTo(' user@domain ') ->setSubject('Mail Test') ->setBodyText("Hello,\nThis is a Zend Mail message...\n") ->setFrom(' sender@domain '); try { $mail->send($transport); echo "Message sent!<br />\n"; } catch (Exception $ex) { echo "Failed to send mail! " . $ex->getMessage() . "<br />\n"; } 
+15
source

Download the minimal Zend package here.

http://framework.zend.com/releases/ZendFramework-1.11.11/ZendFramework-1.11.11-minimal.zip

This is not so much. Uncompressed version - 23 MB. And you have the Zend_Mail class that you need.

0
source

Source: https://habr.com/ru/post/1396435/


All Articles