ruby-on-rails Aws::SES::错误::无效参数值:带附件的嵌套组ruby send_raw_email

flmtquvp  于 2023-01-14  发布在  Ruby
关注(0)|答案(1)|浏览(86)

当我使用aws ses中的ruby文档时,请说:https://www.rubydoc.info/gems/aws-sdk-ses/1.14.0/Aws%2FSES%2FClient:send_raw_email
我试了一下代码,给予了错误:Aws::SES::Errors::InvalidParameterValue: Nested group
我尝试使用send_raw_email发送电子邮件,但使用来自AWS SES for ruby的文档,当我在文档中测试该代码时,程序返回:Aws::SES::Errors::InvalidParameterValue: Nested group且不发送电子邮件

11dmarpk

11dmarpk1#

这是插值的问题,我将使用以下方法解决此问题:

# open and read archive to send in attachment
file = File.open(path_from_csv_created).read

resp = ses_client.send_raw_email(
      source: 'email_send',
      destinations: ['email_to_receive'],
      raw_message: {
        data: <<~MESSAGE
          From: email_send
          To: email_to_receive
          Subject: Test email (contains an attachment)
          MIME-Version: 1.0
          Content-type: Multipart/Mixed; boundary="NextPart"

          --NextPart
          Content-Type: text/plain

          bodyyyy

          --NextPart
          Content-Type: application/csv;
          Content-Disposition: attachment; filename="#{file_csv_name}"

          #{file}
        MESSAGE
      }
    )

相关问题