c12
c12

Reputation: 9827

Spring JavaMailSenderImpl Sending Mail from localhost

I'm using tomcat 7 and Spring 3.0.5 and I'm trying to send email using JavaMailSenderImpl. In order to send mail from my own computer (localhost). I'm able to send email on the real server using the below host/port, but not my local pc. Any ideas?

JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost("localhost");
sender.setPort(25);

Upvotes: 0

Views: 5563

Answers (2)

ilcavero
ilcavero

Reputation: 3082

Check out http://www.aboutmyip.com/AboutMyXApp/DevNullSmtp.jsp for a dummy test smtp server or if you plan to unit test your mail sending logic use Wiser https://github.com/voodoodyne/subethasmtp/blob/master/Wiser.md

Upvotes: 1

Luciano Fiandesio
Luciano Fiandesio

Reputation: 10205

In order to send an email your Spring client need to connect to an SMTP server (http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol). If you don't run an SMTP server on localhost the above code will never work.

Upvotes: 2

Related Questions