首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Joomla的名字

Joomla的名字
EN

Stack Overflow用户
提问于 2012-11-16 11:00:33
回答 2查看 2.8K关注 0票数 1

我开始使用Jmail方法通过分机发送电子邮件:扩展

但是该方法似乎不允许指定收件人的名称,至少我还没有找到这样做的方法。

代码语言:javascript
运行
复制
$mailer->addRecipient($recipient);

文档说:“混合$recipient:字符串或字符串的数组-电子邮件地址(Es)。”

有人知道如何把名字添加到收件人吗?

我使用Joomla2.5,1.5方法有效。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 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');

票数 1
EN

Stack Overflow用户

发布于 2012-12-14 01:12:53

,那是个BUG.

我只是面对同样的问题,无论我如何传递参数,它都不能指定名称。

在Joomla!源代码/库/joomla/mail/mail.php,来自第167行,文档注释如下:

代码语言:javascript
运行
复制
/**
 * 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 从不在函数中使用

代码语言:javascript
运行
复制
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;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13415238

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档