sky

          道,可道,名,可名。

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            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")); //發件人  
                      msg.setRecipient(Message.RecipientType.TO, new InternetAddress("myb4562@163.com")); //收件人  
             
                      msg.setSentDate(new Date()); // 發送日期  
                      msg.setSubject("答話稀有"); // 主題  
                      msg.setText("快點下在"); //內容  
                      // 郵件服務器進行驗證  
                      Transport tran = session.getTransport("smtp");  
                      tran.connect("smtp.163.com", "skiyra", "aaaaaaaaaaaa");  
                      // bluebit_cn是用戶名,xiaohao是密碼  
                      tran.sendMessage(msg, msg.getAllRecipients()); // 發送  
                      System.out.println("郵件發送成功");  
          } catch (AddressException e) {
          e.printStackTrace();
          } catch (MessagingException e) {
          e.printStackTrace();
          } //發件人  
           
          }
          }
          posted on 2012-05-15 20:44 skiyra 閱讀(105) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 察隅县| 龙游县| 天台县| 常宁市| 彭州市| 龙南县| 马公市| 团风县| 梨树县| 文成县| 灵川县| 安岳县| 宜州市| 中宁县| 嘉兴市| 祁阳县| 同仁县| 高平市| 满城县| 花莲市| 上栗县| 鄂伦春自治旗| 锦屏县| 宁津县| 抚顺市| 武定县| 桃源县| 建平县| 勐海县| 阳江市| 铅山县| 延长县| 铁岭市| 民县| 芒康县| 岚皋县| 昔阳县| 阜城县| 安阳市| 濮阳县| 宿州市|