最小化Zend框架到Zend_Mail? [英] Minimizing Zend Framework to Zend_Mail?

查看:103
本文介绍了最小化Zend框架到Zend_Mail?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
在没有实际框架的情况下使用Zend框架组件吗?

Possible Duplicate:
Use Zend Framework components without the actual framework?

我只需要Zend框架的Zend_Mail函数,但是整个框架的大小约为300MB.有没有办法将其缩减为基本内容和Zend_Mail来节省一些磁盘空间?

I just need the Zend_Mail functions of the Zend Framework, but the whole framework is about 300MB in size. Is there a way to cut it down to just the basics and Zend_Mail to save up some disk space?

推荐答案

是的,我之前曾将Zend_Mail与SMTP独立使用,这是我需要的文件.如果您还只想使用sendmail,我也将其缩减为您所需的内容.

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.

如果要使用Sendmail,这是最简单的.您的依存关系是:

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

  • 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
  • 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 those files, here is an example use:

<?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";
}

如果您需要SMTP,则还需要包含更多依赖项.除上述内容外,您还至少需要:

If you need SMTP, then you have a few more dependencies to include. 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/邮件/协议/Smtp/Auth/*
  • 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";
}

这篇关于最小化Zend框架到Zend_Mail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆