• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to send an email using spring framework

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I can't take it! You are too smart for me! Here is the tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic