My code in controller: `
public function filetransport()
{
set_time_limit(0);
$message = new Zend_Mail_Message();
$message->addTo('matthew@zend.com')
->addFrom('ralph.schindler@zend.com')
->setSubject('Greetings and Salutations!')
->setBody("Sorry, I'm going to be late today!");
// Setup File transport
$transport = new Zend_Mail_Transport_File();
$transport->setOptions(array(
'path' => 'data/mail/',
'callback' => function (Zend_Mail_Transport_File $transport) {
return 'Message_' . microtime(true) . '_' . mt_rand() . '.txt';
},
));
$transport->send($message);
}
While creating instance of Zend_Mail_Message it is throwing error.The Error is
Catchable fatal error: Argument 1 passed to Zend_Mail_Message::__construct()
must be of the type array, none given,
called in C:\xampp\htdocs\Zend-Mailer\application\controllers\IndexController.php on line 102
and defined in C:\xampp\htdocs\Zend-Mailer\library\Zend\Mail\Message.php on line 57
If you have idea about this please let me know.....!
According to Zend documentation Zend_Mail_Message
accepts one argument as the parameter. You are not passing any parameter. That is why you get this error.
__construct(array $params)
In addition to the parameters of Zend_Mail_Part::__construct() this constructor supports:
- file filename or file handle of a file with raw message content
- flags array with flags for message, keys are ignored, use constants defined in Zend_Mail_Storage Inherited_from \Zend_Mail_Part::__construct()
From Zend_Mail_Part docs,
Zend_Mail_Part supports different sources for content. The possible params are:
- handler a instance of Zend_Mail_Storage_Abstract for late fetch
- id number of message for handler
- raw raw content with header and body as string
- headers headers as array (name => value) or string, if a content part is found it's used as toplines
- noToplines ignore content found after headers in param 'headers'
- content content as string
That means, as the error is saying, you are missing the params
array in the constructor.