当行插入表格时如何通过邮件通知? [英] How to get notified by mail when rows are inserted into table?

查看:156
本文介绍了当行插入表格时如何通过邮件通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JSP中编写了一个在线商店,并存储在MysQl中。我正在使用servlet和类。当我们在数据库中插入订单时,我想通过邮件通知 admin@domain.com



同样,客户应在收到表单后收到他们输入的电子邮件的订单确认。



我想获得有关如何做这样的任务的反馈。最好的做法是什么?我希望这个问题不要回火,因为我知道有几个答案可能。



基本上,我只是寻找最简单和最快的实现,而不是太麻烦了!



表单中包含非常敏感和机密的数据,如地址等。但是,由于我们的客户可以在网站上跟踪他们的订单,为了安全起见,不应该发送数据。



请指导我正确的方向。

解决方案

如果您使用Hibernate,我建议您使用实体侦听器,特别是使用 @PostPersist 回调。您可以在第6章实体监听器中阅读和回调方法



电子邮件部分可以使用 JavaMail API



您可以检查发送电子邮件的示例使用JavaMail API发送电子邮件



希望它有帮助!


I made an online store coded in JSP and tables stored in MysQl. I'm using servlet and classes. I would like to get notify by mail at admin@domain.com when an order is inserted in the database.

Likewise, the customer should receive the order confirmation to the email they entered when they submit the form.

I would like to get feedback on how to do such a task. What's the best practice? I hope to not get back fire with this question because I`m aware there are several answers possible.

Basically, I`m just looking for the easiest and fastest implementation without too much hassle!

The form contains very sensitive and confidential data like address and such. But, since our customers can track their orders on the site, the data should not be sent, for security purposes. Just a message to confirm the reception of their order.

Please guide me in the right direction.

解决方案

If you are using Hibernate i would recommend you using an entity listener, specially with a @PostPersist callback. You can read about it in Chapter 6. Entity listeners and Callback methods.

The email part can be done using the JavaMail API.

You can check an example of sending an email in Sending an Email using the JavaMail API.

Hope it helps!

这篇关于当行插入表格时如何通过邮件通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆