Home > front end >  How to add the second email address in the body of this email?
How to add the second email address in the body of this email?

Time:01-09

What is the correct way to add $email_2 to the body of this email?

$mail->addCC($email);

$mail->addCC($email_2);
    
/*$mail->addBCC('[email protected]');*/

//Body content
$body = "<p><strong>Hello, </strong>" . $email . " Your message was sent.

What I've tried:

 //Body content
$body = "<p><strong>Hello, </strong>" . $email . " ". $email_2 ." Your message was sent.

Here is the entire bit of code:

$mail->addCC($email);

$mail->addCC($email_2);
    
/*$mail->addBCC('[email protected]');*/

//Body content
$body = "<p><strong>Hello, </strong>" . $email . " Your message was sent.
    
    <br>
 
   <b> Please click reply all when sending emails to this thread so that the Faunna Admins can verify all correspondence. </b><br>
   
  
<br> <br> Your message was Delivered: " . $message . ". Faunna" . $name2 . 
"</p>"; 

Thank you for all the help, here's what ended up doing the trick

//Body content
$body = "<p><strong>Hello, </strong>" . $email . " & $email_2" . " Your message was sent.

CodePudding user response:

Your code is almost correct, you need to close the quote and add a semicolon at the end as well as a paragraph closing. Let's create a paragraph for each email:

$mail->addCC($email);

$mail->addCC($email_2);
    
/*$mail->addBCC('[email protected]');*/

//Body content
$body = "";

foreach ([$email, $email_2] as $current) {
    $body .= "<p><strong>Hello, </strong>" . $current . " Your message was sent.</p>";
}
  •  Tags:  
  • Related