Search code examples
emailjoomlajmail

Joomla Jmail addRecipient with name


I am starting to use the Jmail method to send emails via an extension: http://docs.joomla.org/Sending_email_from_extensions

But the method doesn't seem to allow specifying names for the recipient, at least I haven't found the way to do it.

$mailer->addRecipient($recipient);

The documentation says: "mixed $recipient: Either a string or array of strings [e-mail address(es)]"

Anyone knows how to add the name to the recipient?

I'm using Joomla 2.5, the 1.5 method works.


Solution

  • In Joomla! 2.5 (or starting with the Platform version 11.1) the function accepts two parameters:

    public function addRecipient($recipient, $name = '')

    where

    $recipient - Either a string or array of strings [email address(es)]

    $name - Either a string or array of strings [name(s)]

    Usage:

    $mailer = JFactory::getMailer();

    $mailer->addRecipient('john.doe@example.com', 'John Doe');