0

I am working on a spring (annotation based) application.

One of the page asks user to provide their contact details and message. Once this page is submitted, I want these details to be sent by email to my company ID.

Can someone provide sample example/code which I can use to achieve this functionality? I want to use gmail smpt server.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Sachin
  • 449
  • 2
  • 9
  • 27
  • You might be looking at something like this http://stackoverflow.com/questions/11673221/attach-the-uploaded-file-as-an-email/11673520#comment15757618_11673520 – user525146 Aug 22 '12 at 14:19
  • Special tutorial to do this: http://www.javacodegeeks.com/2010/07/java-mail-spring-gmail-smtp.html – Slava Semushin Sep 05 '12 at 20:28

3 Answers3

2

It sounds like what you want is Java Mail...

http://www.oracle.com/technetwork/java/javamail/index.html

This will allow you to send mail through the gmail smtp server...

smtp.gmail.com (use authentication)

Use Authentication: Yes

Port for TLS/STARTTLS: 587

Port for SSL: 465

According to http://support.google.com/mail/bin/answer.py?hl=en&answer=13287

David
  • 19,577
  • 28
  • 108
  • 128
1

You can either use JavaMail (SMTP) or Google API.

JavaMail is more straightfoward, but use SMTP communication. Google API is a bit longer to get it on, but is web based (REST)

Toilal
  • 3,301
  • 1
  • 24
  • 32
1

Look here: http://static.springsource.org/spring/docs/3.0.x/reference/mail.html

Create a JavaMailSenderImpl bean with the SMTP data from GMail and register it into the application context.

user1606528
  • 181
  • 1
  • 5