Hi,
I am trying to use the option to send individual emails in the custom email action. In a test sending to 3 people, the 1st person (A) gets 3 messages (to A; A,B; and A,B,C). The 2nd person gets 2 emails (to A,B and A,B,C). And the 3rd person gets 1 message (to A,B,C). Looks like a bug in a loop somewhere. I am using a dynamic comma-separated list of addresses ({addresses}).
Also, is there a way to tell if a message is not actually sent? I did a test with a nonexistent email in the list and it was just ignored. The debug statements said it was sent.
Thanks!
I am trying to use the option to send individual emails in the custom email action. In a test sending to 3 people, the 1st person (A) gets 3 messages (to A; A,B; and A,B,C). The 2nd person gets 2 emails (to A,B and A,B,C). And the 3rd person gets 1 message (to A,B,C). Looks like a bug in a loop somewhere. I am using a dynamic comma-separated list of addresses ({addresses}).
Also, is there a way to tell if a message is not actually sent? I did a test with a nonexistent email in the list and it was just ignored. The debug statements said it was sent.
Thanks!
Hi Ensman ,
It does look like a bug in a loop :-( I'll take a look tomorrow.
What do you want to happen if an email isn't sent? Remember that ChronoForms has no way of knowing in an email address exists only if it looks like a valid email address; and there is no message back if an email is subsequently bounced so that can't be reported.
Bob
It does look like a bug in a loop :-( I'll take a look tomorrow.
What do you want to happen if an email isn't sent? Remember that ChronoForms has no way of knowing in an email address exists only if it looks like a valid email address; and there is no message back if an email is subsequently bounced so that can't be reported.
Bob
It sounds like Chronoforms can't do anything about an incorrect email address, unfortunately. Is there something Joomla can do or anything that an administrator could detect? Does the bounced email bounce to anywhere?
Thanks in advance for checking into the other problem!
Thanks in advance for checking into the other problem!
Hi Ensman,
I don't think that there is any magic solution here. If an email is bounced AND a message is returned I think it will usually go to the ReplyTo Address on the sending email. I don't think that Joomla! sees anything (or could see anything) after the message is sent.
I recall looking a year or so ago at some PHP that allowed you to check if the MX record was valid before sending an email. You could add that in a Custom Code action before the Email action to give you one more layer of confirmation. See the David Walsh article here for an example.
Bob
I don't think that there is any magic solution here. If an email is bounced AND a message is returned I think it will usually go to the ReplyTo Address on the sending email. I don't think that Joomla! sees anything (or could see anything) after the message is sent.
I recall looking a year or so ago at some PHP that allowed you to check if the MX record was valid before sending an email. You could add that in a Custom Code action before the Email action to give you one more layer of confirmation. See the David Walsh article here for an example.
Bob
Any luck on the main problem?
I tried to look at your code to see if I could spot anything, but the loop and variables look just fine. Debug statements say it's sending 3 emails to 3 individuals, but when I actually get the mail (as the 3rd person), it says the email was to all 3 addresses!? I can't figure out how this could happen.
I tried to look at your code to see if I could spot anything, but the loop and variables look just fine. Debug statements say it's sending 3 emails to 3 individuals, but when I actually get the mail (as the 3rd person), it says the email was to all 3 addresses!? I can't figure out how this could happen.
Hi Ensman,
I found the problem. You have to re-initialise the Joomla! $mail object each time otherwise it just adds the new To to the existing one. Here's the updated code:
Bob
I found the problem. You have to re-initialise the Joomla! $mail object each time otherwise it just adds the new To to the existing one. Here's the updated code:
if ( $send ) {
// $mail =& JFactory::getMailer();
if ( $individual && count( $recipients ) > 1 ) {
// send individual emails
foreach ( $recipients as $to ) {
$mail =& JFactory::getMailer();
$email_sent = $mail->sendMail( $from_email, $from_name, $to, $subject, $email_body, $sendas, $cc_emails, $bcc_emails, $email_attachments, $replyto_email, $replyto_name );
if ( $email_sent === true ) {
$form->debug['Email info'][$to] = JText::_( 'CF_EM_GH_DEBUG_EMAIL_SENT' );
} else {
$form->debug['Email info'][$to] = JText::sprintf( 'CF_EM_GH_DEBUG_EMAIL_FAIL', $email_sent->toString() );
}
unset($mail);
}
} else {
$mail =& JFactory::getMailer();
$email_sent = $mail->sendMail( $from_email, $from_name, $recipients, $subject, $email_body, $sendas, $cc_emails, $bcc_emails, $email_attachments, $replyto_email, $replyto_name );
if ( $email_sent === true ) {
$form->debug['Email info'][] = JText::_( 'CF_EM_GH_DEBUG_EMAIL_SENT' );
} else {
$form->debug['Email info'][] = JText::sprintf( 'CF_EM_GH_DEBUG_EMAIL_FAIL', $email_sent->toString() );
}
}
} else {
$form->debug['Email info'][] = JText::_( 'CF_EM_GH_DEBUG_EMAIL_STOP' );
}
Bob
Hi Ensman,
I've updated the action on my site and added an updated version of David Walsh's Check MX function as an option for Dynamic addresses - if there isn't a valid MX the email address is dropped.
Bob
I've updated the action on my site and added an updated version of David Walsh's Check MX function as an option for Dynamic addresses - if there isn't a valid MX the email address is dropped.
Bob
This topic is locked and no more replies can be posted.