2012-11-08 3 views
0

이 오류는 나를 괴롭 히고 있습니다. 내 응용 프로그램이 예외를 throw 할 때 전자 메일을 보내려고하지만이 오류가 발생하기 시작했습니다. 호스트를 성공적으로 ping 할 수 있고 nslookup을 사용할 때 로컬 IP 주소를 얻을 수 있습니다. 어떤 아이디어? 감사합니다Java 전자 메일 예외 - SMTP 호스트에 연결할 수 없습니다.

 try 
    { 
     java.util.Date d = new Date(); 
     Properties props = new Properties(); 

     props.setProperty("mail.transport.protocol", "smtp"); 
     props.setProperty("mail.host", "My server address"); 
     props.setProperty("mail.smtp.auth", "true"); 
     props.setProperty("mail.smtp.port", "25"); 

     Authenticator authenticator = new SmtpAuthenticator(); 

     Session mailSession = Session.getDefaultInstance(props, authenticator); 
     Transport transport = mailSession.getTransport(); 

     MimeMessage message = new MimeMessage(mailSession); 
     message.setFrom(new InternetAddress("My email")); 
     message.setSubject("Voicemail Notification"); 
     message.setContent("You are receiving this automatic message because there has been a voicemail left in the system on " +d.toString() + " for the division of the company you work for. \n" + 
     "Please respond promptly. Thanks!\n" + 
     "Private Ip address?file=" + messageName + ".gsm", "text/plain"); 
     message.addRecipient(Message.RecipientType.TO, new InternetAddress(emailTo)); 
     transport.connect(); 
     transport.sendMessage(message, 
       message.getRecipients(Message.RecipientType.TO)); 
     transport.close(); 

     System.out.println("Email Sent!"); 

    } 
    catch(Exception ex) 
    { 
     ex.printStackTrace(); 
     System.out.println("Unable to send email notification to: " + emailTo); 
    } 
+0

텔넷을 사용하여 'telnet mailserver 25'에 연결할 수 있습니까? –

+0

@MitchDempsey, 답변으로 의견을 추가해야하며 동의 할 것입니다. 나는 어리석은 실수를 저질렀다. 총을 뛰어 넘고 질문을 올렸지 만 의견이 도움이되었습니다. 감사합니다 – tier1

+0

좋아, 답변으로 추가되었습니다. –

답변

0

메일 서버가 실제로 실행하고 포트 25에서 수신되는지 여부는 다음 텔넷에서 같은 오류가 발생하면이 메일 서버 인 의미를 알려줍니다 telnet mailserveraddress 25을 시도하는 명령 줄을 사용하십시오 제대로 작동하지 않습니다.

관련 문제