aws-ses icon indicating copy to clipboard operation
aws-ses copied to clipboard

AWS::SES Response Error: InvalidParameterValue - Illegal content

Open Meekohi opened this issue 11 years ago • 5 comments

This is probably an error in my usage, but I can't figure it out.

Mailer.mail_from_address = "Arqball Spin <[email protected]>"
subject = "test"
...
mail :to => "[email protected]",
  :from => Mailer.mail_from_address,
  :subject => subject

I know that the from address is static and works sometimes, so I cannot understand how to debug the following, which seems to be a problem with the Sender field? Is there any way to print the entire request sent to SES for debugging?

AWS::SES Response Error: InvalidParameterValue - Illegal content.
--- !ruby/exception:AWS::SES::ResponseError
message: 'AWS::SES Response Error: InvalidParameterValue - Illegal content.'
response: !ruby/string:AWS::SES::SendRawEmailResponse
  str: !binary |-
    PEVycm9yUmVzcG9uc2UgeG1sbnM9Imh0dHA6Ly9zZXMuYW1hem9uYXdzLmNv
    bS9kb2MvMjAxMC0xMi0wMS8iPgogIDxFcnJvcj4KICAgIDxUeXBlPlNlbmRl
    cjwvVHlwZT4KICAgIDxDb2RlPkludmFsaWRQYXJhbWV0ZXJWYWx1ZTwvQ29k
    ZT4KICAgIDxNZXNzYWdlPklsbGVnYWwgY29udGVudC48L01lc3NhZ2U+CiAg
    PC9FcnJvcj4KICA8UmVxdWVzdElkPjRhMTBkZmMzLWIxNGItMTFlMy1hNWQz
    LWJkZmJkZTgyNTZhMzwvUmVxdWVzdElkPgo8L0Vycm9yUmVzcG9uc2U+Cg==
  action: SendRawEmail
  response: !ruby/object:Net::HTTPBadRequest
    http_version: '1.1'
    code: '400'
    message: Bad Request
    header:
      x-amzn-requestid:
      - 4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3
      content-type:
      - text/xml
      content-length:
      - '268'
      date:
      - Fri, 21 Mar 2014 22:51:07 GMT
    body: |
      <ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
        <Error>
          <Type>Sender</Type>
          <Code>InvalidParameterValue</Code>
          <Message>Illegal content.</Message>
        </Error>
        <RequestId>4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3</RequestId>
      </ErrorResponse>
    read: true
    uri: 
    decode_content: true
    socket: 
    body_exist: true
  body: |
    <ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
      <Error>
        <Type>Sender</Type>
        <Code>InvalidParameterValue</Code>
        <Message>Illegal content.</Message>
      </Error>
      <RequestId>4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3</RequestId>
    </ErrorResponse>
  parsed:
    xmlns: http://ses.amazonaws.com/doc/2010-12-01/
    Error: &1
      Type: Sender
      Code: InvalidParameterValue
      Message: Illegal content.
    RequestId: 4a10dfc3-b14b-11e3-a5d3-bdfbde8256a3
  error: *1

Meekohi avatar Mar 21 '14 23:03 Meekohi

@Meekohi I'm curious if you see the same error if you change Mailer.mail_from_address = "Arqball Spin [email protected]" to Mailer.mail_from_address = "[email protected]" Also the "From" address usually needs to be "verified" by AWS SES. A verification email with a verification link would need to sent to [email protected] before setting it as the "From" email while using SES.

geekdreamzz avatar Mar 31 '14 16:03 geekdreamzz

I think the value of Mailer.mail_from_address would need to be changed to "Arqball Spin <[email protected]>" to get this to work, due to the RFC on the headers.

ajlanghorn avatar Jun 10 '14 21:06 ajlanghorn

@ajlanghorn I don't see the difference from the original code?

Meekohi avatar Jun 10 '14 21:06 Meekohi

@Meekohi Sorry, you're right - I'm being daft.

ajlanghorn avatar Jun 10 '14 21:06 ajlanghorn

The safest way to deal with this issue is tightly wrap your code according to RFCs; i.e. your from address should always look like "\"#{from_name}\" <#{from_email}>".

zakelfassi avatar Sep 12 '14 18:09 zakelfassi