JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » EJB / 其它Java EE 討論區 » JavaMail  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
作者 send mail wthout SSL
chisbtsabc





發文: 24
積分: 0
於 2009-12-04 15:37 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1. Windows Mail 可內送、外寄
內送郵件-POP3: 128.1.1.14
外寄郵件-SMTP: 128.1.1.14
內送郵件伺服器: 使用者: account, 密碼: password
外寄郵件伺服器: 勾選"我的伺服器需要驗證", 登入資訊與內送相同設定

伺服器連接埠號碼
外寄郵件 - SMTP: 25, 不勾選SSL
內送郵件 - POP3: 110, 不勾選SSL





2. JavaMail 發信, 可內送、不能外寄
下面是Code 和 Exception
請問有哪位前輩可以告知可能的原因?
非常感謝!!^^

Exception:
1
2
3
4
5
6
7
   javax.mail.SendFailedException: Invalid Addresses; nested exception is:
   com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
   
   at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1446) at
   com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:736) at
   test.SendMail.mail_login(SendMail.java:118) at
   test.SendMail.mail_login(SendMail.java:60) at


Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
public static void main(String[] args) {
      try{
        
      mail_login("test", "content: "+ new java.util.Date().toString()
        , "<account>@xxxxx.xxx.xx", "<receive account>@gamil.com"
        ,"<account>", "<password>", "128.1.1.14", "25");
 
    }catch(Exception ex){
      ex.printStackTrace();
    }
    }
 
public static void mail_login(String subject, String body,
      String sender, String[] recipients, String account,
      String password, String mailHost, String port) throws Exception {
 
    Properties props = new Properties();
    props.setProperty("mail.transport.protocol", "smtp");
 
    props.put("mail.smtp.host", mailHost);
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.port", port);
    
    //With GMail(SSL)
    // props.put("mail.smtp.socketFactory.port", port);
    // props.put("mail.smtp.socketFactory.class",
    // "javax.net.ssl.SSLSocketFactory");
    // props.put("mail.smtp.socketFactory.fallback", "false");
 
    class SMTPAuthenticator extends javax.mail.Authenticator {
 
      private String username, password;
 
      SMTPAuthenticator(String username, String password) {
        this.username = username;
        this.password = password;
      }
 
      @Override
      public PasswordAuthentication getPasswordAuthentication() {
        PasswordAuthentication au = new PasswordAuthentication(
            username, password);
        return (au);
      }
    }
 
    Session session = Session.getDefaultInstance(props,
        new SMTPAuthenticator(account, password));
    session.setDebug(false);
 
    MimeMessage message = new MimeMessage(session)
 
    message.setFrom(new InternetAddress(sender));
    message.setSender(new InternetAddress(sender));
    message.setSubject(subject);
    // message.setContent(body, "text/plain");
    message.setText(body);
    
 
    for (String loop : recipients) {
      message.addRecipients(Message.RecipientType.TO, InternetAddress
          .parse(loop));
    }
 
    message.saveChanges();
 
    try {
      com.sun.mail.smtp.SMTPTransport tran = (com.sun.mail.smtp.SMTPTransport) session
          .getTransport("smtp");
      tran.connect(mailHost, account, password);
      tran.sendMessage(message, message.getAllRecipients());
    } catch (Exception ex) {
      ex.printStackTrace();
    }
 
    // try {
    // Transport.send(message);
    // } catch (Exception ex) {
    // ex.printStackTrace();
    // }
  }


reply to postreply to post
作者 Re:send mail wthout SSL [Re:chisbtsabc]
chisbtsabc





發文: 24
積分: 0
於 2009-12-11 12:09 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
今天跟Mail Server的人確認了
Server是Exchange

而且也確實是不會支援上述的方式 去轉寄
但他說之前也有廠商發生過
該廠商不知用什麼方法模擬 Outlook

有哪位前輩可以提示那個方法的名稱嗎?
或是Exchange同意幫Outlook轉寄的理由?
只有一個關鍵字也好, 非常感謝


reply to postreply to post
作者 Re:send mail wthout SSL [Re:chisbtsabc]
maisky





發文: 85
積分: 0
於 2009-12-12 02:34 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
http://confluence.atlassian.com/display/JIRAKB/550+5.7.1+Unable+to+relay+for+%28Sending+failed+because+of+invalid+destination+addresses%29

Cause

The Exchange mail server is configured to not not allow users to send mail to external domain.

Resolution

Exchange 2003

Steps to solve the problem:

1. Open the Exchange System Manager
2. Go in Administrative Groups -> Administrative group name -> Server -> Server name -> Protocols -> SMTP
3. Right click on Default SMTP Virtual Server -> properties
4. Access tab -> Relay button
5. Select "only the list bellow" and add your domain and\or IPs you do want to allow the relay.
6. Finally check the "Allow all computers which successfully authenticate to relay, regardless of the list above" checkbox.

Reference: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=742464&SiteID=17
Exchange 2007

For Exchange 2007 you will need to create a second receive connector for external addresses as shown here:

* http://confluence.atlassian.com/display/JIRAKB/Unable+to+Relay+550+5.7.1+Exchange+2007
* You may also see the following from Microsoft's Exchange Team for more background: http://msexchangeteam.com/archive/2006/12/28/432013.aspx


reply to postreply to post
作者 Re:send mail wthout SSL [Re:maisky]
chisbtsabc





發文: 24
積分: 0
於 2009-12-15 15:02 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Thanks, maisky.
I am sorry for delayed the reply and my English is pool.

I already asked manager, the server cannot modify setting, because it is government department.
So I just only work in my web server, and must via mail server for requirement of customer.

I search “Java outlook”, and find Java Outlook Connector, it is software rather than library that I can use, and not free. How it work?

And find the discuss
http://forums.sun.com/thread.jspa?threadID=534240
Should I need to use COM?

Is there a library has invoked Outlook API?


reply to postreply to post
作者 Re:send mail wthout SSL [Re:chisbtsabc]
maisky





發文: 85
積分: 0
於 2009-12-16 11:05 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
不知道這個行不行
Sun Java System Connector for Microsoft Outlook
http://wikis.sun.com/display/CommSuite/Connector+for+Microsoft+Outlook+User%27s+Guide


reply to postreply to post
作者 Re:send mail wthout SSL [Re:chisbtsabc]
chisbtsabc





發文: 24
積分: 0
於 2009-12-18 17:40 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
for maisky

非常感謝

我先試看看

成功與否都會回來PO文^^


reply to postreply to post
作者 Re:send mail wthout SSL [Re:chisbtsabc]
chisbtsabc





發文: 24
積分: 0
於 2010-03-31 09:42 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
結果這陣子在忙別的案子

我老闆直接跟對方說我們無法處理這個問題

所以大概沒下文了唄


reply to postreply to post
» JWorld@TW »  EJB / 其它Java EE 討論區 » JavaMail

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8