Closed leegarner closed 2 years ago
MAIL_sendMessages() in mail.php uses COM_mail() at lines 285-295:
foreach ($toUsers AS $to ) {
if ( defined('DEMO_MODE') ) {
$successes[] = htmlspecialchars ($to[0]);
} else {
if (!COM_mail ($to, $subject, $message, $from, $html, $priority)) {
$failures[] = htmlspecialchars ($to[0]);
} else {
$successes[] = htmlspecialchars ($to[0]);
}
}
}
COM_mail processes $to as follows in lib-common.php at lines 2639-2654:
if ( is_array($to) && isset($to[0]) && $to[0] != '' ) {
if ( isset($to[1]) && $to[1] != '' ) {
if ( filter_var($to[0], FILTER_VALIDATE_EMAIL) ) {
$mail->AddAddress($to[0],$to[1]);
}
} else {
if ( filter_var($to[0], FILTER_VALIDATE_EMAIL) ) {
$mail->AddAddress($to[0]);
}
}
} else {
// assume old style....
if ( filter_var($to, FILTER_VALIDATE_EMAIL) ) {
$mail->AddAddress($to);
}
}
FYI, this is related to the 2.0.0 branch, in 1.7.x COM_emailNotification isn't available yet
Ah. Righto. Your proposed code would appear to resolve the issue in 2.0.0.
Yes, should have clarified, I'm only seeing the issue in 2.0.
COM_emailNotification() expects destination names/addresses in an associative array, but sending mail to a single user uses the results of COM_formatEmailAddress(). This change may not be the right method, but fixes this particular issue without messing up other functions.