2015-08-26 4 views
5

Viene visualizzato questo errore quando tento di inviare un'e-mail dall'app Web Java ospitata su AWS.provato tjavax.mail.MessagingException: host SMTP sconosciuto: "smtp.office365.com";

Ho già provato a cambiare il server SMTP a smtp.live.com e anche a smtp-mail.outlook.com, nessuno di questi lavori.

Può essere una configurazione di AWS? Funziona su Ubuntu. (Non ci sono restrizioni in uscita sul server stesso, ci potrebbe essere qualche sul server di Java però)

codice per l'invio della e-mail:

final String username = smtpUsername; 
    final String password = smtpPwd; 
    Properties props = new Properties(); 
    props.put("mail.smtp.auth", "true"); 
    props.put("mail.smtp.starttls.enable", "true"); 
    props.put("mail.smtp.host", smtpHost); 
    props.put("mail.smtp.port", smtpPort); 
    Session session = Session.getInstance(props, new javax.mail.Authenticator() { 
     protected PasswordAuthentication getPasswordAuthentication() { 
      return new PasswordAuthentication(username, password); 
     } 
    }); 
    try { 
     Message message = new MimeMessage(session); 
     message.setFrom(new InternetAddress(smtpUsername)); 
     message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(sendTo)); 
     message.setSubject(subject); 
     message.setContent(content); 
     Transport.send(message); 
     System.out.println("Sent"); 
    } catch (MessagingException e) { 
     e.printStackTrace(); 
    } 

La parte più interessante di questo è, che funziona dal mio computer locale ... (ma solo quando ho disattivare Avast)

ho cercato di eseguire telnet smtp.office365.com 587 e il risultato è stato:

Trying 132.245.195.162... 
Connected to outlook-emeawest2.office365.com. 
Escape character is '^]'. 
220 HE1PR08CA0021.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 26 Aug 2015 14:32:11 +0000 

ho trie d per configurare l'AWS SMTP (SES) e ricevo lo stesso errore, anche dopo aver seguito la documentazione, ho anche aggiunto l'email da cui stavo inviando e alla quale stavo inviando le e-mail verificate (whitelist):

javax.mail.MessagingException: Unknown SMTP host: "email-smtp.eu-west-1.amazonaws.com"; 

risposta

1

provare a fare uno scavo da una shell bash dalla macchina Ubuntu

scavo email-smtp.eu-west-1.amazonaws.com

dove vuoi arrivare. da quello che posso vedere, potrebbe essere un problema DNS.