0

我正在为 java 使用 Sparkpost 客户端库。

当我设置 afromEmailusernameto时,contentAttributes我希望在收到的电子邮件中看到 Name Name 而不是 name@mydomain.com。但它不起作用。有没有办法在消息中显示名称而不是电子邮件?

我需要我的名字而不是电子邮件地址的地方

TemplateContentAttributes contentAttributes = new TemplateContentAttributes();

    AddressAttributes addressAttributes = new AddressAttributes();
    addressAttributes.setName(username);
    addressAttributes.setEmail(fromEmail);

    contentAttributes.setFrom(addressAttributes);
    contentAttributes.setSubject(subject);
    contentAttributes.setHtml(html);
    contentAttributes.setText(text);
4

1 回答 1

1

Java SparkPost 库的维护者在这里。我刚刚修改了这个示例

我把它改成这样:

TemplateContentAttributes contentAttributes = new TemplateContentAttributes();
AddressAttributes fromAddress = new AddressAttributes(from);
fromAddress.setName("My Name");
contentAttributes.setFrom(fromAddress);

这就是结果 在此处输入图像描述

是否有可能“用户名”是一个空字符串。如果您查看电子邮件客户端中的源代码,您会看到友好名称吗?

如果您仍有问题,请分享发送到服务器的 JSON。

于 2017-05-08T20:18:58.860 回答