java - 构建电子邮件并将其发送出去
问题描述
我们的前端使用带有 Java 后端的 React。我们希望让用户能够将页面上的信息通过电子邮件发送给其他人。环顾四周,我可以看到有些人使用 React 作为电子邮件模板,他们会生成 HTML,然后将其发送到后端(https://assertible.com/blog/creating-email-templates-with -react-components)(https://building.lang.ai/how-to-build-emails-with-react-fcf941b125d1),但我想知道这是否是正确的方法。
哪种方法会更好?
- 当点击 email 按钮时,将 react 组件与 props 一起转换为 HTML 并发送到后端发送出去。从前端传出的 json 看起来像:
{
to: <>,
from: <>,
subject: <>,
body: <where the html would go>,
additionalComments: <>
}
- 单击电子邮件按钮时,我们发送会将适当的信息从前端发送到后端,后端将生成电子邮件。从前端传出的 json 看起来像:
{
to: <>,
from: <>,
subject: <>,
foo: <>,
bar: <>,
additionalComments: <>
}
我倾向于第一种方法,但我不确定标准是什么。第一种方法允许我重用我在 React 中已有的组件,并将后端简单地用作电子邮件服务器。第二种方法可以让我们保留更多信息,也无需发送 html。
解决方案
推荐阅读
- javascript - 如何仅接受来自我自己的应用程序的请求?
- ios - View 中的手势识别器并使用 View Controller 作为目标,我的设计错了吗?
- docker - 如何从 dotnet core 2.2 和 powershell core 创建一个 docker 镜像?
- c# - 如何修复:NullReferenceException:不要创建自己的模块实例,从 ParticleSystem 实例中获取它们
- python - 尝试以块的形式读取文本并将其加载到列表中但出现错误
- python - 如何使用最多请求限制(compute.instances.listReferrers)修复谷歌控制台界面计算引擎删除操作
- javascript - 发出 GET 请求时出错“加载资源失败:net::ERR_CONNECTION_REFUSED”
- python - scrapy 从网站下载 excel
- mysql - 在 mysqli 8.0.5 配置时应用配置错误:写入配置 | 无效的模板
- go - Go Logging 未出现