Why is my phpmailer unable to send multiple emails?

108 Views Asked by At

I'm using phpmailer to send email. The code works fine if I'm sending it to just one email address but it won't send to multiple addresses. Is there a configuration that I need to do the mail class or something?

The code is as follows:

 $subject="Subject";
 $to_name="To Someone";
 $to="[email protected]";
 $toCc="[email protected]";
 $message=wordwrap($message,50);
 $from_name="TruMoxy";
 $from='[email protected]';
 $mail = new PHPMailer(); 
 $mail->SMTPAuth = true; 
 $mail->SMTPSecure = 'ssl'; 
 $mail->Host = "smtp.outserver.net";
 $mail->SMTPAuth=true;
 $mail->Port = 465;
 $mail->IsHTML(true);
 $mail->Username = "username";
 $mail->Password = "password";
 $mail->SetFrom($from, 'TruMoxy');
 $mail->Subject = $subject;
 $mail->Body = "body";

 $mail->AddAddress($to,'person1');  
 $mail->AddCC($toCc,'person2');


if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}

I've been trying to make this work for almost a week and it seems like something simple but I can't find anything wrong with my limited knowledge of the mailer. Any help with this problem would be very greatly appreciated. Thanks.

2

There are 2 best solutions below

0
On

After much trial and error I finally found that there was absolutely nothing wrong with my code. My site is hosted by Godaddy and they happen to have issues with having phpmailer on a Linux server. If I send multiple emails to other secureserver.net email precipitants it works fine. I found a discussion on it here:

PHPMailer GoDaddy Server SMTP Connection Refused.

0
On

If you don't use ssl certification then Try to modify your existing code by below mentioned code and hope this will works fine.

$mail->Host = 'localhost';
$mail->Port = 25;  
$mail->ssl = false;
$mail->authentication = false;