锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久精品视频在线看,欧美一区二区视频17c,在线精品国产http://www.aygfsteel.com/ashutc/category/47659.html鏈夊灝戦潰璇曢鏄痗trl+c鐒跺悗ctrl+v鐨勫憿錛熻冮偅涔堥毦鐨勯鐪熺殑鍏誨緱璧蜂箞錛?/description>zh-cnThu, 20 Jan 2011 07:16:29 GMTThu, 20 Jan 2011 07:16:29 GMT60javaMail涓や釜鐗堟湰http://www.aygfsteel.com/ashutc/archive/2011/01/20/343260.html瑗跨摐瑗跨摐Thu, 20 Jan 2011 07:16:00 GMThttp://www.aygfsteel.com/ashutc/archive/2011/01/20/343260.htmlhttp://www.aygfsteel.com/ashutc/comments/343260.htmlhttp://www.aygfsteel.com/ashutc/archive/2011/01/20/343260.html#Feedback0http://www.aygfsteel.com/ashutc/comments/commentRss/343260.htmlhttp://www.aygfsteel.com/ashutc/services/trackbacks/343260.html
<?xml version="1.0" encoding="UTF-8"?>  

<beans xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:aop="http://www.springframework.org/schema/aop"    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">  

  
<bean id="mailSender"    class="org.springframework.mail.javamail.JavaMailSenderImpl">   <property name="host">  

  
<value>127.0.0.1</value><!-- 鏈湴鏈嶅姟鍣?nbsp; 濡傛灉鏄叾浠栵紝璇峰~濡傦細smtp.sohu.com-->

   
</property>   

 
<property name="javaMailProperties">

    
<props>  

          
<prop key="mail.smtp.auth">true</prop>  

                
<prop key="mail.smtp.timeout">25000</prop>  

            
</props>  

        
</property>  

        
<property name="username">  

            
<value>postmaster@mai.com</value> <!-- 鎴戣繖閲岀敤鏈湴鐨勯偖綆卞悕--> 

        
</property>  

        
<property name="password">  

            
<value>123456</value>  

        
</property>  

    
</bean>  

</beans>

鐒跺悗寤虹珛涓涓猨ava鏂囦歡

 

package org.fantlam.spring;

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import org.springframework.mail.SimpleMailMessage;

import org.springframework.mail.javamail.JavaMailSender;

 

public class SpringMail1 {

public static void main(String args[]){

 ApplicationContext ctx 
=new ClassPathXmlApplicationContext("applicationContext.xml");   

  JavaMailSender sender 
= (JavaMailSender) ctx.getBean("mailSender");   

 SimpleMailMessage mail 
= new SimpleMailMessage();

//榪欓噷SimpleMailMessage鍙兘鐢ㄦ潵鍙戦乼ext鏍煎紡鐨勯偖浠?/span>

  
try {   

  mail.setTo(
"fantlam@163.com");//鎺ユ敹鑰?nbsp;  

  mail.setFrom(
"sohu@mai.com");//鎸夊墠闈㈣鐨勶紝鍙互闅忎究璧?/span>

  mail.setSubject(
"spring mail test!");//涓婚   

  mail.setText(
"springMail鐨勭畝鍗曞彂閫佹祴璇?/span>");//閭歡鍐呭   

  sender.send(mail);   

 } 
catch (Exception e) {   

  e.printStackTrace();   

 }   

 

}

}




import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMail {
 
/**
  * 
@param args
  
*/
 
public static void main(String[] args) {
   Properties props 
= System.getProperties();  
         
// 璁劇疆smtp鏈嶅姟鍣?nbsp; 
         props.setProperty("mail.smtp.host""smtp.126.com");  
         
// 鐜板湪鐨勫ぇ閮ㄥ垎smpt閮介渶瑕侀獙璇佷簡  
         props.put("mail.smtp.auth""true");  
  
         Session s 
= Session.getInstance(props);  
         
// 涓轟簡鏌ョ湅榪愯鏃剁殑淇℃伅  
         s.setDebug(true);  
         
// 鐢遍偖浠朵細璇濇柊寤轟竴涓秷鎭璞?nbsp; 
         MimeMessage message = new MimeMessage(s);  
         
try {  
             
// 鍙戜歡浜?nbsp; 
             InternetAddress from = new InternetAddress("ashutc@126.com");  
             message.setFrom(from);  
             
// 鏀朵歡浜?nbsp; 
             InternetAddress to = new InternetAddress("ashutc@126.com");  
             message.setRecipient(Message.RecipientType.TO, to);  
             
// 閭歡鏍囬  
             message.setSubject("test");  
             String content 
= "嫻嬭瘯鍐呭";  
             
// 閭歡鍐呭,涔熷彲浠ヤ嬌綰枃鏈?text/plain"  
             message.setContent(content, "text/html;charset=GBK");  
  
             
/****涓嬮潰浠g爜鏄彂閫侀檮浠?***** 
             String fileName = "d:\\hello.txt"; 
             MimeBodyPart messageBodyPart = new MimeBodyPart(); 
             messageBodyPart.setText("Hi"); 
             Multipart multipart = new MimeMultipart(); 
             multipart.addBodyPart(messageBodyPart); 
 
             messageBodyPart = new MimeBodyPart(); 
             DataSource source = new FileDataSource(fileName); 
             messageBodyPart.setDataHandler(new DataHandler(source)); 
             messageBodyPart.setFileName(fileName); 
             multipart.addBodyPart(messageBodyPart); 
 
             message.setContent(multipart);
*/ 
               
             message.saveChanges();  
             Transport transport 
= s.getTransport("smtp");  
             
// smtp楠岃瘉錛屽氨鏄綘鐢ㄦ潵鍙戦偖浠剁殑閭鐢ㄦ埛鍚嶅瘑鐮?nbsp; 
             transport.connect("smtp.126.com""ashutc""*******");  
             
// 鍙戦?nbsp; 
             transport.sendMessage(message, message.getAllRecipients());  
             transport.close();  
  
         } 
catch (Exception e) {  
             e.printStackTrace();  
         }  
 }
}



















瑗跨摐 2011-01-20 15:16 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 翁牛特旗| 吉水县| 屯昌县| 来凤县| 化德县| 原阳县| 平武县| 沅陵县| 瑞丽市| 苗栗县| 兴海县| 华阴市| 湖北省| 磴口县| 涞水县| 三穗县| 阳山县| 宜春市| 类乌齐县| 岳池县| 宿迁市| 正安县| 江源县| 嘉黎县| 大连市| 潮安县| 昭通市| 斗六市| 呼和浩特市| 博兴县| 博白县| 固原市| 青龙| 酉阳| 高尔夫| 同德县| 连山| 屯昌县| 钟祥市| 贵溪市| 九江市|