您好,我正在使用AWS SES SDK V2发送电子邮件。我遇到了一个发件人名称类似Michael čisto
的情况。如果我将此名称直接传递给AWS电子邮件输入结构,则会出现以下错误:operation error SESv2: SendEmail, https response error StatusCode: 400, BadRequestException: Missing '"'
下面是我的代码:
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
awsconfig "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/sesv2"
"github.com/aws/aws-sdk-go-v2/service/sesv2/types"
)
func main() {
name := "Michael čisto"
body := "test email body"
subject := "test email"
CharSet := "UTF-8"
/* Assemble the email */
input := &sesv2.SendEmailInput{
Destination: &types.Destination{
CcAddresses: []string{},
ToAddresses: []string{receiverEmail},
},
Content: &types.EmailContent{
Simple: &types.Message{
Body: &types.Body{
Html: &types.Content{
Charset: aws.String(CharSet),
Data: aws.String(body),
},
},
Subject: &types.Content{
Charset: aws.String(CharSet),
Data: aws.String(subject),
},
},
},
ReplyToAddresses: []string{"\"" + name + "\" <" + senderEmail + ">"},
FromEmailAddress: aws.String("\"" + name + "\" <" + senderEmail + ">"),
}
cfg, err := awsconfig.LoadDefaultConfig(context.TODO(),
awsconfig.WithRegion("us-east-1"),
)
client := sesv2.NewFromConfig(cfg)
emailResp, err = client.SendEmail(context.TODO(), input)
}
有谁能帮我弄清楚如何在围棋中逃脱这些角色吗?
1条答案
按热度按时间kgsdhlau1#
尝试使用mail.Address.String格式化地址:
如果您的域包含非ASCII字符:
请注意,Amazon SES不支持SMTPUTF 8扩展。如果地址的域部分(@符号后的部分)包含非ASCII字符,则必须使用Punycode进行编码(请参阅types.BulkEmailEntry)。
mail.Address.String
不支持此功能。但您可以使用idna.ToASCII自行转换域。