如何使用AWS SES在电子邮件中放置标签



我使用此代码使用AWS SES:发送电子邮件

package com.amazonaws.samples;
import java.io.IOException;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder;
import com.amazonaws.services.simpleemail.model.Body;
import com.amazonaws.services.simpleemail.model.Content;
import com.amazonaws.services.simpleemail.model.Destination;
import com.amazonaws.services.simpleemail.model.Message;
import com.amazonaws.services.simpleemail.model.SendEmailRequest; 
public class AmazonSESSample {
static final String FROM = "sender@example.com";
static final String TO = "recipient@example.com";
static final String SUBJECT = "Amazon SES test (AWS SDK for Java)";
static final String HTMLBODY = "Amazon SES test (AWS SDK for Java)";
static final String TEXTBODY = "This email was sent through Amazon SES ";
public static void main(String[] args) throws IOException {
try {
AmazonSimpleEmailService client = 
AmazonSimpleEmailServiceClientBuilder.standard().withRegion(Regions.US_EAST_1).build()
SendEmailRequest request = new SendEmailRequest()
.withDestination(
new Destination().withToAddresses(TO))
.withMessage(new Message()
.withBody(new Body()
.withHtml(new Content()
.withCharset("UTF-8").withData(HTMLBODY))
.withText(new Content()
.withCharset("UTF-8").withData(TEXTBODY)))
.withSubject(new Content()
.withCharset("UTF-8").withData(SUBJECT)))
.withSource(FROM)
client.sendEmail(request);
System.out.println("Email sent!");
} catch (Exception ex) {
System.out.println("The email was not sent. Error message: " 
+ ex.getMessage());
}
}
}

现在,我的问题是,我必须给这封电子邮件添加一个标签,这样收件人才能看到:

MyLabel<example.com>

而不是接收器当前看到的内容:

sender@example.com

根据AWS SES的开发者指南,

您可以在不执行额外的验证步骤。要向电子邮件地址添加标签,请添加账户名称和"账户"之间的加号(+(;在";符号(@(,后面跟着一个文本标签。例如,如果您已经验证sender@example.com,您可以使用发件人+myLabel@example.com作为"从";或";返回路径";您的电子邮件地址。你可以使用这个功能来实现可变包络返回路径(VERP(。然后你可以使用VERP从中检测和删除无法送达的电子邮件地址您的邮件列表。

但是,如果我将FROM更改为";发件人+MyLabel@example.com&";,电子邮件被发送为:

发件人+MyLabel@example.com

尽管如此,我已经验证了我的FROM电子邮件地址。请帮忙。

我通过将FROM变量的值从";sender@example.com"至";myLabel<sender@example.com>quot;

静态最终字符串FROM="myLabel<sender@example.com>quot;;

相关内容

  • 没有找到相关文章

最新更新