anymail / django-anymail

Django email backends and webhooks for Amazon SES, Brevo (Sendinblue), MailerSend, Mailgun, Mailjet, Postmark, Postal, Resend, SendGrid, SparkPost, Unisender Go and more

Home Page:https://anymail.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Missing final '@domain'

anuj-scanova opened this issue · comments

Reporting an error? It's helpful to know:

  • Anymail version: django-anymail[amazon_ses]==8.6
  • ESP (Mailgun, SendGrid, etc.): AWS SES
  • Your ANYMAIL settings (change secrets to "redacted")
EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend"
ANYMAIL = {
    'AMAZON_SES_MESSAGE_TAG_NAME': 'Type',
    'WEBHOOK_SECRET': os.environ.get('ANYMAIL_WEBHOOK_SECRET', '')
}
  • Versions of Django, requests, python
    ** Django: django==3.2.14
    ** requests: requests==2.28
    ** python: 3.9
  • Exact error message and/or stack trace
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/anymail/backends/amazon_ses.py", line 67, in post_to_esp
    response = payload.call_send_api(self.client)
  File "/usr/local/lib/python3.9/site-packages/anymail/backends/amazon_ses.py", line 127, in call_send_api
    return ses_client.send_raw_email(**self.params)
  File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 508, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 915, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Missing final '@domain'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/decorators/debug.py", line 89, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "/app/authentication/views.py", line 278, in dispatch
    return super().dispatch(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/generics.py", line 190, in post
    return self.create(request, *args, **kwargs)
  File "/app/authentication/views.py", line 322, in create
    user = self.perform_create(serializer)
  File "/usr/local/lib/python3.9/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/app/authentication/views.py", line 341, in perform_create
    complete_signup(self.request, user, allauth_settings.EMAIL_VERIFICATION, None)
  File "/usr/local/lib/python3.9/site-packages/allauth/account/utils.py", line 186, in complete_signup
    return perform_login(
  File "/usr/local/lib/python3.9/site-packages/allauth/account/utils.py", line 168, in perform_login
    response = adapter.pre_login(request, user, **hook_kwargs)
  File "/usr/local/lib/python3.9/site-packages/allauth/account/adapter.py", line 412, in pre_login
    send_email_confirmation(request, user, signup=signup, email=email)
  File "/usr/local/lib/python3.9/site-packages/allauth/account/utils.py", line 319, in send_email_confirmation
    email_address.send_confirmation(request, signup=signup)
  File "/usr/local/lib/python3.9/site-packages/allauth/account/models.py", line 59, in send_confirmation
    confirmation.send(request, signup=signup)
  File "/usr/local/lib/python3.9/site-packages/allauth/account/models.py", line 166, in send
    get_adapter(request).send_confirmation_mail(request, self, signup)
  File "/usr/local/lib/python3.9/site-packages/allauth/account/adapter.py", line 549, in send_confirmation_mail
    self.send_mail(email_template, emailconfirmation.email_address.email, ctx)
  File "/usr/local/lib/python3.9/site-packages/allauth/account/adapter.py", line 140, in send_mail
    msg.send()
  File "/usr/local/lib/python3.9/site-packages/django/core/mail/message.py", line 284, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.9/site-packages/anymail/backends/base.py", line 94, in send_messages
    sent = self._send(message)
  File "/usr/local/lib/python3.9/site-packages/anymail/backends/base.py", line 124, in _send
    response = self.post_to_esp(payload, message)
  File "/usr/local/lib/python3.9/site-packages/anymail/backends/amazon_ses.py", line 70, in post_to_esp
    raise AnymailAPIError(str(err), backend=self, email_message=message, payload=payload,
anymail.exceptions.AnymailAPIError: An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Missing final '@domain'
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Missing final '@domain'
  • Any other relevant code and settings (e.g., for problems
    sending, your code that sends the message)

SES IAM permission is giving the following error
Screen Shot 2022-07-14 at 1 13 13 PM

It looks like SendRawEmail is not supported.
There looks like SendEmail and SendBulkEmail are two permissions required

Screen Shot 2022-07-14 at 1 28 10 PM

I don't think that has anything to do with IAM permissions. That error message seems to be saying one of the email addresses in your message is missing an '@​domain'.

What are the from_email and to addresses involved? Are they valid email addresses? Any commas appearing outside quotes? (Have you set whatever django-allauth uses to specify the from address?)

As far as the IAM console warning, it looks like you're in a section for managing Pinpoint Email, which is a separate AWS multichannel marketing communications service built on top of Amazon SES v2. Anymail uses the ses:SendRawEmail API from SES v1, and has nothing to do with Amazon Pinpoint.