dou72260 2017-03-11 14:02
浏览 262
已采纳

AWS SES不使用SendRawEmail操作发送电子邮件

I have troubles sending emails with AWS golang sdk using SendRawEmail operation. Even though I get no errors and receive MessageId back from AWS, I do not receive the email.

Sending emails using SendEmail works fine and I receive the email.

My code:

  session, err := session.NewSession()
  if err != nil {
    return err
  }

  svc := ses.New(session, &aws.Config{Region: aws.String("eu-west-1")})

  messageContent := `From: "Alice" <xxx@xxx>
To: "Bob" <xxx@xxx>
Return-Path: <xxx@xxx>
Subject: Hello
Content-Language: en-US
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0

This is a test email`

  base64messageContent := base64.StdEncoding.EncodeToString([]byte(messageContent))

  source := aws.String("xxx@xxx")
  destinations := []*string{aws.String("xxx@xxx")}
  message := ses.RawMessage{Data: []byte(base64messageContent)}

  input := ses.SendRawEmailInput{Source: source, Destinations: destinations, RawMessage: &message}

  output, err := svc.SendRawEmail(&input)

  if err != nil {
    return err
  }

  log.Println("Response from SES", output)

  return nil
}

I am using my Gmail as the destination email, if that makes any difference.

  • 写回答

1条回答 默认 最新

  • dsfliu1129 2017-03-12 18:31
    关注

    Data in RawData should not be base64 encoded. As documentation states:

    // Data is automatically base64 encoded/decoded by the SDK.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料