简体   繁体   English

使用Java发送自动电子邮件

[英]Sending automatic emails with java

I need to send automatic emails every certain time from my spring mvc application. 我需要每隔一定时间从spring mvc应用程序发送自动电子邮件。 I have been researching some tools like 我一直在研究一些工具,例如

  • quartz 石英
  • ScheduledExecutorService ScheduledExecutorService
  • ScheduledFuture 预定未来
  • Timer 计时器
  • TimerTask 计时器任务

My question is that i need to send those emails even if the pc is turned off, i suppose that i have some kind of server in my work if this task cant not be done by only using my application. 我的问题是,即使PC已关闭,我也需要发送这些电子邮件,我想我的工作中有某种服务器,如果仅使用我的应用程序无法完成此任务。 If that is the case what should i do to my server to make this task? 如果是这种情况,我应该对服务器执行此任务吗?

thanks in advance 提前致谢

if you have a server, you just need to deploy your spring application with a scheduler. 如果您有服务器,则只需要使用调度程序部署spring应用程序即可。 here are the examples 这是例子

configure the time when you want to send the email , the server needs to be running to complete its scheduler task. 配置您要发送电子邮件的时间 ,服务器需要运行以完成其调度程序任务。

A very simple method would be to integrate your e-mail script into a cron job in which you specify an time interval to execute your script. 一种非常简单的方法是将电子邮件脚本集成到cron作业中,在其中您指定执行脚本的时间间隔。

One line cron job script 一线cron作业脚本

A really great API which empowers developers to send emails is called Mailgun . 一个使开发人员能够发送电子邮件的非常出色的API称为Mailgun Zapier complements Mailgun really well, and allows you to schedule tasks to fire off when ever you choose. Zapier很好地补充了Mailgun,并允许您安排任务以随时选择触发。 This article demonstrates how developers have integrated Zapier and Mail Gun. 文章演示了开发人员如何整合Zapier和邮件枪。 Both these services have a free tier which is pretty reasonable for small to mid-sized projects which your office's internal tool might fall under. 这两种服务都有免费层,对于您的办公室内部工具可能属于的中小型项目而言,这是相当合理的。

Please let me know if you have any questions! 请让我知道,如果你有任何问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM