3

I've got a form that allows users to send an article to friends. The friends are set in a $recipient array. I can dump the array and it looks fine:

var_dump($recipients);
// array (size=2)
0 => test@example.com
1 => test2@example.com

So far so good. Then the array is added to the $mail object:

$mail = JFactory::getMailer();
$mail->addRecipient($recipients);

I am using mailtrap.io to track the mailing and test where they are sent. The second email (to test2@example.com) never gets sent. The first one does. So I have to assume there's a problem with how Joomla is handling the array of recipients. This is Joomla 3.3.6

Any ideas?

  • 1
    Have you var_dumped the object after you added the recipients to verify they've been added? I took a look at the JMail class and there's logic to handle arrays. There's another entry point, perhaps manually looping through and using $mail->add($recipient) could be a workaround. – Brian Bolli Oct 22 '14 at 23:29
3

Here is a hypothesis based on what I seen in the source code.

I don't see anything that looks like there is any problem with adding the recipient. Are you using SMTP? With SMTP you can use the variable $mail->SMTPDebug = true This should echo the request if made via SMTP.

Either way PHPMailer (what joomla uses) loops through the recipients and sends them an email each, if there is any kind of limiter in the PHP mail settings or SMTP server settings that could be the reason. You could try adding them as a CC though if that is an option.

If this is the case you could try mandrill http://mandrill.com/. It has a very nice SMTP service and is free up to 12000 emails (a month). But, with some hosts SMTP requests tend to be blacklisted. So again mandrill is a reasonable idea as it comes with an http API. There is also an extension that overrides JMail to us it. https://compojoom.com/joomla-extensions/mandrill-transactional-emails-made-easy

We use this heavily and since doing so we have had little to no problems with emails. It is all free too until you reach a certain threshold that is difficult to reach.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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