-1

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="email1@example.com";
 $toCc="email2@example.com";
 $message=wordwrap($message,50);
 $from_name="TruMoxy";
 $from='admin@trumoxy.com';
 $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.

CloudyKooper
  • 727
  • 3
  • 19
  • 47

2 Answers2

0

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.

Community
  • 1
  • 1
CloudyKooper
  • 727
  • 3
  • 19
  • 47
0

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;
vignesh Subash
  • 2,577
  • 1
  • 11
  • 15