2011-01-14 11 views
0

私は[email protected]のJavaMail 1.4.3メール送信かかわらExchange 2003の

試し{ プロパティのp = System.getPropertiesのためにリレーすることができません550 5.7.1()を取得しておきます。

 p.put("mail.smtp.host", "server IP"); 
     p.put("mail.smtp.port", "25"); 
     p.put("mail.debug", "true"); 
     Session s = Session.getDefaultInstance(p); 

     Message msg = new MimeMessage(s); 

     msg.setFrom(new InternetAddress(from)); 

     msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to)); 

     msg.setSubject(subject); 

     Multipart mp = new MimeMultipart(); 

     BodyPart bp = new MimeBodyPart(); 
     bp.setText(message); 

     mp.addBodyPart(bp); 

     msg.setContent(mp); 

     Transport t = s.getTransport("smtp"); 
     t.send(msg); 
     return 0; 
    } catch (Exception e) { 
     e.printStackTrace(); 
     return 1; 
    } 

答えて

0

あなたの交換サーバーは、送信しているIPの中継を許可していない可能性がありますか?または、中継する前に認証が必要な場合があります。

+0

イムからIP提出は設定され、許可されます。認証に関しては、管理者は電子メールを送信する必要はないと言った。私は間違っていると推測しています。 ここで、認証を続けると、どのようにしてそれが可能になりますか? –

+0

うーん...おそらくこの質問を見てみてくださいhttp://stackoverflow.com/questions/4337812/javamail-ntlm-authentication-failure NTLMは、通常交換が望むものです。 –

1

まず、交換機smtpにログインする必要があります。

String host = "smtp.gmail.com; 
String username = "user"; 
String password = "passwd"; 
Properties props = new Properties(); 
props.put("mail.smtps.auth", "true"); 
// ... 
MimeMessage msg = new MimeMessage(session); 
// set the message content here 
Transport t = session.getTransport("smtps"); 
try { 
t.connect(host, username, password); 
t.sendMessage(msg, msg.getAllRecipients()); 
} finally { 
t.close(); 
} 

または

変更あなたの交換の設定は、Exchange Serverのオフ を中継するためにログインすることなく、

許可のアプリケーションサーバーを送信できるようにする2007 http://msexchangeteam.com/archive/2006/12/28/432013.aspx

関連する問題