2015-08-26 15 views
5

Tôi gặp phải lỗi này khi tôi cố gắng gửi email từ ứng dụng web Java được lưu trữ trên AWS.đã thử tjavax.mail.MessagingException: Máy chủ SMTP không xác định: "smtp.office365.com";

Tôi đã cố gắng thay đổi máy chủ SMTP thành smtp.live.com và cũng smtp-mail.outlook.com, không có công cụ nào trong số đó hoạt động.

Có thể cấu hình AWS không? Nó chạy trên Ubuntu. (Không có giới hạn ngoài trên máy chủ riêng của mình, có thể có một số trên Java máy chủ mặc dù)

Mã để gửi email:

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(); 
    } 

Phần thú vị nhất của việc này là, nó hoạt động từ của tôi máy tính cục bộ ... (nhưng chỉ khi tôi vô hiệu hóa Avast)

tôi đã cố gắng để thực hiện telnet smtp.office365.com 587 và kết quả là:

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 

tôi có Trie d để thiết lập SMTP AWS (SES) và tôi nhận được lỗi tương tự, ngay cả sau khi tôi làm theo tài liệu, tôi cũng đã thêm email mà tôi đã gửi và gửi đến email đã xác minh (danh sách trắng):

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

Trả lời

1

thử làm một cuộc khai quật từ một vỏ bash từ máy ubuntu

đào email-smtp.eu-west-1.amazonaws.com

gì là bạn nhận được. từ những gì tôi có thể thấy, nó có thể là một vấn đề DNS.

Các vấn đề liên quan