I have the following code in Java to send an email
props.setProperty("mail.smtp.host", host);
props.setProperty("mail.smtp.starttls.enable", "false");
props.setProperty("mail.smtp.port", port);
props.setProperty("mail.smtp.user", user);
props.setProperty("mail.smtp.auth", "true");
htmlBody = Disenio(tercero, titulo, mensaje);
Session session = Session.getDefaultInstance(props);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(user));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(mailDestino));
message.setSubject(titulo); //adjuntar asunto...
message.setContent( htmlBody, "text/html");
Transport t = session.getTransport("smtp");
t.connect(user, pass);
t.sendMessage(message, message.getAllRecipients());
t.close();
I have the following code in php to send the mail
$mail=new PHPMailer();
$mail->isSMTP();
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPAuth=true;
$mail->Host=$host;
$mail->Username=$user;
$mail->Password=$pass;
$mail->SMTPSecure= 'tls';
$mail->Port= 25;
$mail->AddAddress($mailDestino);
$mail->Subject = $titulo;
$mail->isHTML(true);
$mail->Body=$this->Disenio($tercero,$titulo,$mensaje);
$mail->AltBody=$mensaje;
$mail->setLanguage('es');
if($mail->send()){
$result="OK";
}else{
$result="Mail Error".$mail->ErrorInfo;
}
I use the same host, user and password in both, in Java I WORK but in Php NO, I get the following error:
Mail ErrorError SMTP: The following destinations failed: [email protected]: Verification failed for Unrouteable address Sender verify failed
Reading on the internet I read that the error is due to a problem with the mail server because of some configuration or something, but if Java was not so, it should not work for me, that's why I wanted to place the comparison of the two languages, which are two different languages but I do not think it's because of the mail server because in java it works perfectly for me.