I want to make it so that the CC field is optional to have, but right now, the email only sends if there is a cc field, and doesn’t send if it’s not filled out. Here’s my code:
$mail->addAddress($EmailTo);
$mail->addCC($CC);
$mail->Subject = $Subject;
$mail->Body = nl2br($Message);
$mail->AltBody = nl2br($Message);
$mail->isHTML(false);
$mail->send();
I also tried to add this since I thought it’s throwing an error because the CC field was empty
if (isset($_POST['emailfrom'])) {
$mail->AddCC($CC);
} else {
$mail->send();
}
New contributor
Lucy Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.