drewblas / aws-ses

Provides an easy ruby DSL & interface to AWS SES
MIT License
549 stars 109 forks source link

AWS::SES Response Error: InvalidParameterValue - Illegal content #51

Open Meekohi opened 10 years ago

Meekohi commented 10 years ago

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

Mailer.mail_from_address = "Arqball Spin <noreply@arqspin.com>"
subject = "test"
...
mail :to => "meekohi@gmail.com",
  :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
geekdreamzz commented 10 years ago

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

ajlanghorn commented 10 years ago

I think the value of Mailer.mail_from_address would need to be changed to "Arqball Spin <noreply@arqspin.com>" to get this to work, due to the RFC on the headers.

Meekohi commented 10 years ago

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

ajlanghorn commented 10 years ago

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

zakelfassi commented 9 years ago

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}>".