我开始使用 Jmail 方法通过扩展发送电子邮件:http: //docs.joomla.org/Sending_email_from_extensions
但是该方法似乎不允许为收件人指定名称,至少我还没有找到方法。
$mailer->addRecipient($recipient);
文档说:“混合$recipient:字符串或字符串数组 [e-mail address(es)] ”
任何人都知道如何将名称添加到收件人?
我正在使用 Joomla 2.5,1.5 方法有效。
我开始使用 Jmail 方法通过扩展发送电子邮件:http: //docs.joomla.org/Sending_email_from_extensions
但是该方法似乎不允许为收件人指定名称,至少我还没有找到方法。
$mailer->addRecipient($recipient);
文档说:“混合$recipient:字符串或字符串数组 [e-mail address(es)] ”
任何人都知道如何将名称添加到收件人?
我正在使用 Joomla 2.5,1.5 方法有效。
在 Joomla!2.5(或从平台版本 11.1 开始)该函数接受两个参数:
public function addRecipient($recipient, $name = '')
在哪里
$recipient - 字符串或字符串数组 [电子邮件地址]
$name - 字符串或字符串数组 [name(s)]
用法:
$mailer = JFactory::getMailer();
$mailer->addRecipient('john.doe@example.com', 'John Doe');
那是一个BUG。
我只是面临同样的问题,无论我如何传递参数,它都无法指定名称。
在 Joomla!源代码 /libraries/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;
}