spring发送javamail配置

  1. <!-- our Authenticator implementation toeomail#gmail-->  
  2.     <bean id="smtpAuthenticator"  
  3.         class="com.XXXX.SmtpAuthenticator">  
  4.         <constructor-arg value="[email protected]" />  
  5.         <constructor-arg value="XXXXXXX" />  
  6.     </bean>  
  7.   
  8.     <!-- now setup an authenticated session -->  
  9.     <bean id="mailSession" class="javax.mail.Session"  
  10.         factory-method="getInstance">  
  11.         <constructor-arg>  
  12.             <props>  
  13.                 <prop key="mail.smtp.auth">true</prop>  
  14.                 <prop key="mail.smtp.socketFactory.port">465</prop>  
  15.                 <prop key="mail.smtp.socketFactory.class">  
  16.                     javax.net.ssl.SSLSocketFactory  
  17.                 </prop>  
  18.                 <prop key="mail.smtp.socketFactory.fallback">  
  19.                     false  
  20.                 </prop>  
  21.             </props>  
  22.         </constructor-arg>  
  23.         <constructor-arg ref="smtpAuthenticator" />  
  24.     </bean>  
  25.   
  26.     <!-- and configure the MailSender with the authenticated session -->  
  27.     <bean id="mailSender"  
  28.         class="org.springframework.mail.javamail.JavaMailSenderImpl">  
  29.         <property name="host" value="smtp.gmail.com" />  
  30.         <property name="session" ref="mailSession" />  
  31.     </bean>  
  32.   
  33.     <!-- this is a template message that we can pre-load with default state -->  
  34.     <bean id="templateMessage"  
  35.         class="org.springframework.mail.SimpleMailMessage">  
  36.         <property name="from" value="[email protected]" />  
  37.         <property name="subject" value="Testing" />  
  38.     </bean>  
  39.   
  40.     <bean id="sendMailService"  
  41.         class="com.XXXXX.SendMailService">  
  42.         <constructor-arg ref="mailSender" />  
  43.         <constructor-arg ref="templateMessage" />  
  44.     </bean>  

你可能感兴趣的:(spring,bean,.net,Gmail)