sky

          道,可道,名,可名。

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            1 Posts :: 0 Stories :: 0 Comments :: 0 Trackbacks
          public class SendMail {
          public static void main(String[] args) {
                  try {
                      Properties p = new Properties(); //Properties p = System.getProperties();  
                      p.put("mail.smtp.auth", "true");  
                      p.put("mail.transport.protocol", "smtp");  
                      p.put("mail.smtp.host", "smtp.163.com");  
                      p.put("mail.smtp.port", "25");  
                      //建立會話  
                      Session session = Session.getInstance(p);  
                      Message msg = new MimeMessage(session); //建立信息  
             
                      msg.setFrom(new InternetAddress("skiyra@163.com")); //發(fā)件人  
                      msg.setRecipient(Message.RecipientType.TO, new InternetAddress("myb4562@163.com")); //收件人  
             
                      msg.setSentDate(new Date()); // 發(fā)送日期  
                      msg.setSubject("答話稀有"); // 主題  
                      msg.setText("快點下在"); //內容  
                      // 郵件服務器進行驗證  
                      Transport tran = session.getTransport("smtp");  
                      tran.connect("smtp.163.com", "skiyra", "aaaaaaaaaaaa");  
                      // bluebit_cn是用戶名,xiaohao是密碼  
                      tran.sendMessage(msg, msg.getAllRecipients()); // 發(fā)送  
                      System.out.println("郵件發(fā)送成功");  
          } catch (AddressException e) {
          e.printStackTrace();
          } catch (MessagingException e) {
          e.printStackTrace();
          } //發(fā)件人  
           
          }
          }
          posted on 2012-05-15 20:44 skiyra 閱讀(104) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網站導航:
           
          主站蜘蛛池模板: 寿阳县| 深泽县| 神农架林区| 博兴县| 攀枝花市| 汪清县| 印江| 永寿县| 新郑市| 武隆县| 曲靖市| 同仁县| 晋城| 古交市| 德惠市| 太仓市| 四平市| 鄂托克旗| 扶余县| 曲阳县| 高邑县| 会理县| 上饶市| 舒城县| 克东县| 永平县| 中宁县| 平舆县| 锦州市| 绥江县| 阿荣旗| 石渠县| 兰西县| 桐梓县| 巍山| 永吉县| 孟州市| 工布江达县| 洪洞县| 樟树市| 韶关市|