jsp 이메일 보내기

2217 단어
package com.chinashare.util;

import java.util.*;  
import javax.mail.*;  
import javax.mail.internet.*;  
   
public class SendEmail{  
    public static void main(String[] args) {  
    	SendEmail send=new SendEmail();
    	String result= send.SendEmail("[email protected]"," "," 
" + "http://chinashare.sinaapp.com"); System.out.println(result); } // : , , public String SendEmail(String address,String title ,String content){ try { 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); // // , html msg.setContent(content,"text/html;charset=utf8"); msg.setFrom(new InternetAddress("[email protected]")); // msg.setRecipient(Message.RecipientType.TO, new InternetAddress(address)); // msg.setSentDate(new Date()); // msg.setSubject(title); // msg.setText(content); // // Transport tran = session.getTransport("smtp");
				        // ,  
              tran.connect("smtp.163.com", "[email protected]", "zxcvbnm123");  
              tran.sendMessage(msg, msg.getAllRecipients()); //  
             
     
          } catch (Exception e) {  
              e.printStackTrace();  
              return "SendErroy" ;
          } 
         return "SendOk" ;
    }
}

좋은 웹페이지 즐겨찾기