[英]How to send emails from spring application using gmail?
I am working on a spring (annotation based) application. 我正在开发spring(基于注释)应用程序。
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.
提交此页面后,我希望通过电子邮件将这些详细信息发送到我的公司ID。
Can someone provide sample example/code which I can use to achieve this functionality? 有人可以提供可用于实现此功能的示例示例/代码吗? I want to use gmail smpt server.
我想使用Gmail smpt服务器。
It sounds like what you want is Java Mail... 听起来您想要的是Java Mail ...
http://www.oracle.com/technetwork/java/javamail/index.html http://www.oracle.com/technetwork/java/javamail/index.html
This will allow you to send mail through the gmail smtp server... 这将允许您通过gmail smtp服务器发送邮件...
smtp.gmail.com (use authentication) smtp.gmail.com(使用身份验证)
Use Authentication: Yes 使用身份验证:是
Port for TLS/STARTTLS: 587 TLS / STARTTLS的端口:587
Port for SSL: 465 SSL连接埠:465
According to http://support.google.com/mail/bin/answer.py?hl=en&answer=13287 根据http://support.google.com/mail/bin/answer.py?hl=zh_CN&answer=13287
You can either use JavaMail (SMTP) or Google API . 您可以使用JavaMail (SMTP)或Google API 。
JavaMail is more straightfoward, but use SMTP communication. JavaMail更直接,但是使用SMTP通信。 Google API is a bit longer to get it on, but is web based (REST)
Google API需要更长的时间才能使用,但它是基于Web的(REST)
Look here: http://static.springsource.org/spring/docs/3.0.x/reference/mail.html 在这里查看: 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. 使用来自GMail的SMTP数据创建JavaMailSenderImpl bean,并将其注册到应用程序上下文中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.