将响应ID从SendGrid保存到Spring Boot DB
我正在使用SendGrid Mail模板发送邮件,并且正常工作。邮件适当地发送给具有适当身体的接收者。现在,我提出了一个新的要求,即通过使用sendgrid,它为您提供了您发送的每个邮件的事务ID。现在,我必须将其保存在DB中。谁能帮我吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用SendGrid API发送邮件时,响应为空,因此您不会返回ID。
但是,您可以做的是为整个请求或每个个性化设置
custom_args
中的任何内容。custom_args
在每个跟踪事件。因此,您可以生成自己的ID并存储该ID,然后当您从API接收事件时,您将获得该ID为custom_args
,并且可以将事件归因于原始电子邮件。我写了一篇有关上,但我在Spring Boot中没有例子。
When you send a mail with the SendGrid API the response is empty, so you don't get an ID back.
However, what you can do is set anything you like in the
custom_args
for either the entire request or for each personalisation.custom_args
are sent back in the parameters for every tracking event. So, you can generate your own ID and store that, then when you receive an event from the API, you will get that ID as thecustom_args
and can attribute the event to the original email.I wrote a blog post about how to do this in Ruby on Rails, but I don't have an example in Spring Boot.