mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Refactor sendSiteEmail function to handle BCC and address logic
Updated the sendSiteEmail function to differentiate between adding BCC recipients and direct addresses based on the count of recipients. This change enhances the email sending logic and improves clarity in the code.
This commit is contained in:
parent
7cdfab9b07
commit
c75197cb13
1 changed files with 16 additions and 7 deletions
|
@ -120,7 +120,7 @@ function sendSiteEmail($to, $subject, $message, $fromEmail = '', $fromName = '')
|
|||
setSiteSendMessage($mail);
|
||||
/**
|
||||
* @var \PHPMailer\PHPMailer\PHPMailer $mail
|
||||
*/
|
||||
*/
|
||||
$mail->setFrom($fromEmail, $fromName);
|
||||
if (strpos($subject, $webSiteTitle) === false) {
|
||||
$mail->Subject = $subject . " - " . $webSiteTitle;
|
||||
|
@ -129,11 +129,20 @@ function sendSiteEmail($to, $subject, $message, $fromEmail = '', $fromName = '')
|
|||
}
|
||||
$mail->msgHTML($message);
|
||||
$count = 0;
|
||||
foreach ($piece as $value) {
|
||||
$totalCount++;
|
||||
$count++;
|
||||
_error_log("sendSiteEmail::addBCC [{$count}] {$value}");
|
||||
$mail->addBCC($value);
|
||||
if(count($piece) > 1){
|
||||
foreach ($piece as $value) {
|
||||
$totalCount++;
|
||||
$count++;
|
||||
_error_log("sendSiteEmail::addBCC [{$count}] {$value}");
|
||||
$mail->addBCC($value);
|
||||
}
|
||||
}else{
|
||||
foreach ($piece as $value) {
|
||||
$totalCount++;
|
||||
$count++;
|
||||
_error_log("sendSiteEmail::addAddress [{$count}] {$value}");
|
||||
$mail->addAddress($value);
|
||||
}
|
||||
}
|
||||
//_error_log("sendSiteEmail::sending now count=[{$count}] [{$totalCount}/{$totalEmails}]");
|
||||
|
||||
|
@ -275,7 +284,7 @@ function sendEmailToSiteOwner($subject, $message)
|
|||
setSiteSendMessage($mail);
|
||||
/**
|
||||
* @var \PHPMailer\PHPMailer\PHPMailer $mail
|
||||
*/
|
||||
*/
|
||||
$mail->setFrom($contactEmail, $webSiteTitle);
|
||||
$mail->Subject = $subject . " - " . $webSiteTitle;
|
||||
$mail->msgHTML($message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue