So this is my code where I send same email to 3 different users

$mailer->sendMail($emailfrom, $sitename, '[email protected]', $subject, $message, 1);
$mailer->sendMail($emailfrom, $sitename, '[email protected]', $subject, $message, 1);
$mailer->sendMail($emailfrom, $sitename, '[email protected]', $subject, $message, 1);

And this is what I see in my gmail (My email is the last one [email protected]):

enter image description here

But I don't want that all successive recipients see to who email was sent before. How can it be solved? I can't find anything on JMail's API page:


Using Joomla 3.5.1

3 Answers 3


As you can see on the API reference page, the sendMail() function has a $bcc parameter:

sendMail(string $from, string $fromName, mixed $recipient, string $subject, string $body, boolean $mode = false, mixed $cc = null, mixed $bcc = null, mixed $attachment = null, mixed $replyTo = null, mixed $replyToName = null)

Also, if you're sending the same email to 3 different recipients, you don't need to use the sendMail() function 3 times, but instead, simply define an array of recipients.

Have a try of the following:

$to = array(
    '[email protected]'

$bcc = array(
    '[email protected]',
    '[email protected]'

$mailer->sendMail($emailfrom, $sitename, $to, $subject, $message, 1, null, $bcc);
  • Using cc or bcc seems to be the best solution for sending multiple emails. I tried another solution, that can be used, but doesn't seem to be the best solution and looks more like a workaround.
    – Adam M.
    Jun 7, 2016 at 7:15

There are 2 solutions you can try of the following.

  • By avoiding the mailer instance : $mailerand using the following code -


JFactory::getMailer()->sendMail($emailfrom, $sitename, '[email protected]', $subject, $message, 1);
JFactory::getMailer()->sendMail($emailfrom, $sitename, '[email protected]', $subject, $message, 1);
JFactory::getMailer()->sendMail($emailfrom, $sitename, '[email protected]', $subject, $message,1);`

Refer for more details :


  • Take an array of recipients and place the mailer instance inside the loop as following -


$recipients = array('email1','email2','email3' );
    $mailer = JFactory::getMailer();
    $mailer->Encoding = 'base64';
    $mailer->setSubject('Your subject string');
    $send = $mailer->Send();

Refer for more details:


  • Ye this seems to solve the problem. I think that by default it should clean the recipients array each time we call sendMail() funcion, maybe it doesn't because we have email's cc and bcc which seems to be the best option to send multiple emails and thats why I'm going to accept Lodder's answer and for you +1 :)
    – Adam M.
    Jun 7, 2016 at 7:11
  • not an issue :) whichever you find the best solution for you. I find this method appropriate so I use this.
    – Liz.
    Jun 7, 2016 at 7:17

Joomla Mailer extends the PHPMailer, so you can add this line of code after the send()


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.