Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add CC in PHP Mailer not working

Tags:

php

Im trying to send on email to user using AddAddress and another three emails to admin and so on by CC .
I can send out email using AddAdress() But not using Add CC.
Below is my code.

<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "mail.test.com.my"; // SMTP server

$mail->From     = "[email protected]";
$mail->AddAddress($email);

$mail->Subject  = "Colourful email";
$mail->Body     =$message;
/*$mail->WordWrap = 50;*/
$mail->AddCC    =($email_1);
$mail->AddCC    =($email_2);
$mail->AddCC    =($email_3);

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Kindly check your email for the confirmation of your rental.Thank you.';
}

?>
like image 561
ling Avatar asked Aug 06 '14 06:08

ling


People also ask

Does PHPMailer need SMTP?

For PHPMailer to be able to send emails from your PHP app, you will need to connect it to an SMTP server. We suggest you first use an email testing tool such as Mailtrap Email Sandbox and its SMTP server to test the functionality before sending anything to real recipients.

Does PHPMailer work on localhost?

The PHPMailer library provides the easiest way to send an email from localhost with an SMTP server using PHP. Not only the text email, but you can also send HTML email from localhost in PHP using PHPMailer.

Is PHPMailer secure?

But SPEWS can be worse than annoying: thanks to a security vulnerability in a popular web software component called PHPMailer, crooks could use your “contact us” form to take over your whole website. 24/7 threat hunting, detection, and response delivered by an expert team as a fully-managed service.


2 Answers

You dont need to = in this

$mail->AddCC($email_1);
like image 135
TBI Avatar answered Sep 20 '22 09:09

TBI


Try with this additional parameter

$mail->AddCC('[email protected]', 'Person One');
$mail->AddCC('[email protected]', 'Person Two');
like image 20
Sudharsun Avatar answered Sep 20 '22 09:09

Sudharsun