aspose file tools*
The moose likes Other Application Frameworks and the fly likes How to send an email using spring framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "How to send an email using spring framework" Watch "How to send an email using spring framework" New topic
Author

How to send an email using spring framework

Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
I used to send an forgot password email through spring framework.

but I'm getting the following exception

Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset; nested exception is org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException:

applicationContext.xml:
<bean name="/ForgotPasswordAction"
class="com.fiskars.teacherstools.web.action.ForgotPasswordAction">
<property name="teacherDelegate">
<ref bean="teacherDelegate"/>
</property>
<property name="emailDelegate">
<ref bean="emailDelegate"/>
</property>
</bean>
<!-- Mail Configurations -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.yahoo.com"/>
</bean>

<!-- this is a template message that we can pre-load with default state -->
<bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage"></bean>


in the Mail java

public void sendMessage(String from, String to, String subject, String body) throws TeacherEmailException {
try {
LOG.debug("sending a mail from Email Manager");
LOG.debug("From : "+from +"\t"+"To :" + to + " Sub:"+subject+"Body: "+body);
mailMessage.setFrom(from);
mailMessage.setTo(to);
mailMessage.setSubject(subject);
mailMessage.setText(body);
mailSender.send(mailMessage);
LOG.debug("mail sent");
}
catch (Exception e) {
LOG.error("Exeption Occurred in sendMessage \n Exception: "+e.toString());
throw new TeacherEmailException(e.getMessage(),e);
}
}



Properties file:
from=skkuchipudi@gmail.com
to=skuchipudi@yahoo.com
subject=Your Requested Password
body=<P>Your requested password is attached below, please find and login into our website.



How can I send an email for testing with yahoo/gmail domain?
Couild you please give me suggestion?

thanks,
Sumant K


Thanks,
Kumar
 
 
subject: How to send an email using spring framework