Hi Everyone,

I have done like this.

web.xml
----------
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml /WEB-INF/mailContext.xml
</param-value>
</context-param>

applicationContext.xml
--------------------------

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/mail.properties</value>
<value>WEB-INF/jdbc.properties</value>
</list>
</property>
</bean>

<!-- Mail Sender -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
<property name="host"><value>${mail.host}</value></property>
</bean>


mailContext.xml
-------------------

<beans>
<bean id="emailSender" class="com.mailtest.SA2MailSender">
<property name="mailSender"><ref bean="mailSender"/></property>
</bean>
</beans>


SA2MailSender.java
-----------------------

package com.mailtest;

import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;


public class SA2MailSender {

/** Creates a new instance of SA2MailSender */
public SA2MailSender() {
}

private MailSender mailSender;

public void setMailSender(MailSender mailSender) {
this.mailSender = mailSender;
}
public void sendMail(){
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("[email protected]");
message.setTo("[email protected]");
message.setSubject("springframework.");
message.setText("Received mail.");
this.mailSender.send(message);
}
}


mail.properties
-----------------
mail.host = my smtp host.


How to call the SA2MailSender program?
from either a bean or jsp.

Thank You,
Regards,
Kotesh.