【发布时间】:2020-08-07 18:26:07
【问题描述】:
我需要使用 Postmark 发送包含模板的电子邮件。我的项目没有使用 Postmark 库,而是使用配置了令牌和 url 的 Feign Client。
但是,这种方法使得用数据填充模板变得更加困难。如何将 Spring 应用程序中的数据注入位于resources 文件夹的模板中?
这是我的 feign 客户端和 dto 类:
@FeignClient(value = "postmark", url = "${email.postmark-url}", configuration = PostmarkConfig.class)
public interface PostmarkFeignClient {
@RequestMapping(method = RequestMethod.POST, consumes = "application/json")
@Headers({"Content-Type: application/json", "Accept: application/json"})
PostmarkResponse sendEmailWithTemplate(@RequestBody PostmarkRequest postmarkRequest);
}
这里是 PostmarkRequest:
private String from;
private String to;
private String cc;
private String subject;
private String replyTo;
private String htmlBody;
private String textBody;
private Long templateId;
private Object templateModel;
private String templateAlias;
private boolean inlineCss = true;
【问题讨论】:
标签: java spring spring-boot feign postmark