简体   繁体   English

Zend Framework发送邮件

[英]Zend Framework Send Mail

Is it possible to send array values as body of the zend mail.For example, 是否可以将数组值作为zend邮件的正文发送。例如,

$mail=new Zend_Mail();
$params=$this->getRequest()->getParams();
$mail->setSubject('Order products');
$mail->addTo('recipient@gmail.com','Recipient');
$mail->setBodyText($params['products']); // $params['products'] array
$mail->setFrom('someone@gmail.com','Name');

But this doesn't seem to work. 但这似乎不起作用。

You will have always an empty body this way, you need to convert your array into String 这样您将始终有一个空的主体,需要将数组转换为String

The BodyText is an object(Zend_Mime_Part), along with other information this object contains a content field, the problem is : befor adding the content to the mime_part object it passes throu rtrim(), so as result you will have an empty string passed as content. BodyText是一个对象(Zend_Mime_Part),以及该对象包含内容字段的其他信息,问题是:由于将内容添加到它通过rtrim()传递的mime_part对象中,因此结果将有一个空字符串作为内容。

rtrim() expects parameter 1 to be string, ....\\library\\Zend\\Mime.php on line 170 rtrim()期望参数1为字符串,第170行上的.... \\ library \\ Zend \\ Mime.php

i used this way and it worked for me.. 我用这种方式,它为我工作。

$mail = new Zend_Mail();
$mail->setFrom('someone@gmail.com');
$mail->setBodyHtml($oForm->getValue('text'));
$mail->addTo(array('xyz.aaa@web.com', 'eee@web.com'));
$mail->setSubject('support mail');
$mail = new Zend_Mail('utf-8');
$mail->setBodyHtml($message)
->setFrom('abc@gty.com', 'abc')
->addTo($to, 'admin')
->setSubject($subj);

Here $message contains all table contents retrieved from Post . 这里$message包含从Post检索的所有表内容。
Suggestion given by @Pekka is an important one. @Pekka给出的@Pekka很重要。
Hope this helps you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM