Saturday, July 31, 2010

Sending e-mails in Java with Spring – GMail SMTP server example Read more: Java Code Geeks: Sending e-mails in Java with Spring – GMail SMTP-Part 2

The corresponding Spring XML file that bootstraps the container is the following:

01xml version="1.0" encoding="UTF-8"?>
02
10 xsi:schemaLocation="
17>
18
19 <context:component-scan base-package="com.javacodegeeks.spring.mail" />
20
21 <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
22 <property name="host" value="smtp.gmail.com"/>
23 <property name="port" value="25"/>
24 <property name="username" value="myusername@gmail.com"/>
25 <property name="password" value="mypassword"/>
26 <property name="javaMailProperties">
27 <props>
28
29 <prop key="mail.transport.protocol">smtpprop>
30
31 <prop key="mail.smtp.auth">trueprop>
32
33 <prop key="mail.smtp.starttls.enable">trueprop>
34 <prop key="mail.debug">trueprop>
35 props>
36 property>
37 bean>
38
39 <bean id="alertMailMessage" class="org.springframework.mail.SimpleMailMessage">
40 <property name="from">
41 <value>myusername@gmail.comvalue>
42 property>
43 <property name="to">
44 <value>myusername@gmail.comvalue>
45 property>
46 <property name="subject" value="Alert - Exception occurred. Please investigate"/>
47 bean>
48
49beans>


Read more: Java Code Geeks: Sending e-mails in Java with Spring – GMail SMTP server example http://www.javacodegeeks.com/2010/07/java-mail-spring-gmail-smtp.html#ixzz0vF2cGLgT

No comments:

Post a Comment