I currently have an application that sends emails through phpmailer .
The problem is that it only sends emails that have the domain of my company.
When there is an email that is gmail domain, hotmail or another domain, it does not send and displays the following message:
warning: mail() [function mail]: SMTP server response: 550.5.7.1 <[email protected]>... Relaying denied. IP name possibly forged [191...] in line 100
my 100 line contains:
mail($destinatario,$asunto,$body);
The data I use from smtp is an email from my company.
I think it's a security configuration that I do not have, can someone help me?
$sql = "select EMAIL1_CLI from planilla";
$rpt = mysqli_query($sub_db,$sql)or die(mysqli_error());
//$asunto = 'Aviso de Deuda';
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = "Este es un mensaje automatico...";
$mail->From = "[email protected]";
$mail->FromName = "Francisco Acevedo Diaz";
$mail->AddAddress('[email protected]','Clientes'); //deb poner variable que traiga mail y nombre del cliente
$mail->SetFrom('[email protected]', 'Depto. Cobranza');
$asunto = $mail->Subject = 'Aviso de deuda en oriental Motors';
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$mail->IsSMTP();
$mail->Host = "mail.xx.cl";
// optional
// used only when SMTP requires authentication
$mail->SMTPAuth = true;
$mail->Username = 'xx';
$mail->Password = 'xx';
while ($des = mysqli_fetch_array($rpt)) {
$destinatario = $des["EMAIL1_CLI"];
printf ($destinatario);
//$mail->AddAddress = $des['EMAIL1_CLI'];
//$mail->AddAddress("[email protected]");
mail($destinatario,$asunto,$body);
}
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
} else {
echo "Message sent!";
}
}
Edition 2 (send the emails to all, but send as 5 emails to each recipient):
$sql = "select EMAIL1_CLI from planilla";
$rpt = mysqli_query($sub_db,$sql)or die(mysqli_error());
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = "Este es un mensaje automatico...";
$mail->From = "[email protected]";
$mail->FromName = "Francisco Acevedo";
$mail->SetFrom('[email protected]', 'Depto. Cobranza');
$asunto = $mail->Subject = 'Aviso de deuda en oriental Motors';
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$mail->IsSMTP();
$mail->Host = "mail.xx.cl";
$mail->SMTPAuth = true;
$mail->Username = 'xx';
$mail->Password = 'xx';
while ($des = mysqli_fetch_array($rpt)) {
$destinatario = $des["EMAIL1_CLI"];
$mail->AddAddress($destinatario);
$mail->send();
}