- <!-- our Authenticator implementation toeomail#gmail-->
- <bean id="smtpAuthenticator"
- class="com.XXXX.SmtpAuthenticator">
- <constructor-arg value="XXXXXl@gmail.com" />
- <constructor-arg value="XXXXXXX" />
- </bean>
- <!-- now setup an authenticated session -->
- <bean id="mailSession" class="javax.mail.Session"
- factory-method="getInstance">
- <constructor-arg>
- <props>
- <prop key="mail.smtp.auth">true</prop>
- <prop key="mail.smtp.socketFactory.port">465</prop>
- <prop key="mail.smtp.socketFactory.class">
- javax.net.ssl.SSLSocketFactory
- </prop>
- <prop key="mail.smtp.socketFactory.fallback">
- false
- </prop>
- </props>
- </constructor-arg>
- <constructor-arg ref="smtpAuthenticator" />
- </bean>
- <!-- and configure the MailSender with the authenticated session -->
- <bean id="mailSender"
- class="org.springframework.mail.javamail.JavaMailSenderImpl">
- <property name="host" value="smtp.gmail.com" />
- <property name="session" ref="mailSession" />
- </bean>
- <!-- this is a template message that we can pre-load with default state -->
- <bean id="templateMessage"
- class="org.springframework.mail.SimpleMailMessage">
- <property name="from" value="XXXXX@gmail.com" />
- <property name="subject" value="Testing" />
- </bean>
- <bean id="sendMailService"
- class="com.XXXXX.SendMailService">
- <constructor-arg ref="mailSender" />
- <constructor-arg ref="templateMessage" />
- </bean>