显然,匿名函数无法序列化。
例
$function = function () { return "ABC";};serialize($function); // would throw error从您的代码中,您正在使用Closure:
$callback = function () // <---------------------- Issue{ return 'ZendMail_' . microtime(true) . '.tmp';};解决方案1: 替换为正常功能
例
function emailCallback() { return 'ZendMail_' . microtime(true) . '.tmp';}$callback = "emailCallback" ;解决方案2: 通过数组变量间接调用方法
如果您查看
http://docs.mnkras.com/libraries_23rdparty_2_zend_2_mail_2_transport_2file_8php_source.html
public function __construct($options = null) 63 { 64 if ($options instanceof Zend_Config) { 65 $options = $options->toArray(); 66 } elseif (!is_array($options)) { 67 $options = array(); 68 } 69 70 // Making sure we have some defaults to work with 71 if (!isset($options['path'])) { 72 $options['path'] = sys_get_temp_dir(); 73 } 74 if (!isset($options['callback'])) { 75 $options['callback'] = array($this, 'defaultCallback'); <- here 76 } 77 78 $this->setOptions($options); 79 }您可以使用相同的方法发送回调
$callback = array($this,"aMethodInYourClass");



