• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic