我开始使用Jmail方法通过分机发送电子邮件:扩展
但是该方法似乎不允许指定收件人的名称,至少我还没有找到这样做的方法。
$mailer->addRecipient($recipient);文档说:“混合$recipient:字符串或字符串的数组-电子邮件地址(Es)。”
有人知道如何把名字添加到收件人吗?
我使用Joomla2.5,1.5方法有效。
发布于 2012-11-16 11:36:49
在Joomla!2.5中(或从平台11.1版开始),该函数接受两个参数:
public function addRecipient($recipient, $name = '')
哪里
$recipient -字符串或字符串数组电子邮件地址(Es)
$name -字符串或字符串名称数组
用法:
$mailer = JFactory::getMailer();
$mailer->addRecipient('john.doe@example.com', 'John Doe');
发布于 2012-12-14 01:12:53
,那是个BUG.
我只是面对同样的问题,无论我如何传递参数,它都不能指定名称。
在Joomla!源代码/库/joomla/mail/mail.php,来自第167行,文档注释如下:
/**
* Add recipients to the email
*
* @param mixed $recipient Either a string or array of strings [email address(es)]
* @param mixed $name Either a string or array of strings [name(s)]
*
* @return JMail Returns this object for chaining.
*
* @since 11.1
*/好吧,但是变量$name 从不在函数中使用:
public function addRecipient($recipient, $name = '')
{
// If the recipient is an array, add each recipient... otherwise just add the one
if (is_array($recipient))
{
foreach ($recipient as $to)
{
$to = JMailHelper::cleanLine($to);
$this->AddAddress($to);
}
}
else
{
$recipient = JMailHelper::cleanLine($recipient);
$this->AddAddress($recipient);
}
return $this;
}https://stackoverflow.com/questions/13415238
复制相似问题