Currently I am using the following script. This script will send an email to email1, but not always.
When somebody adds the second email2, the email only goes to number 2.
I want to change the script to sent to both emails (1 and 2) when email2 exists.
Tried a lot of things, but can't get it right.
if(!$row->email2){
$email = $row->email1;
} else{
$email = $row->email2;
// Tried this below and a lot more
if(!$row->email2){
$email = $row->email1;
} else{
$email = $row->email1;
$email = $row->email2;
// E-mail to
if(!is_array($email)){
$mail->ClearAddresses();
$mail->AddAddress($email);
$mail->Send();
} else{
foreach($email as $email){
$mail->ClearAddresses();
$mail->AddAddress($email);
$mail->Send();
$emails = array();
if($email = $row->email1) {
$emails[] = $email;
}
if($email = $row->email2) {
$emails[] = $email;
}
foreach($email as $email){
$mail->ClearAddresses();
$mail->AddAddress($email);
$mail->Send();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.