Giter Club home page Giter Club logo

Comments (4)

medmunds avatar medmunds commented on September 22, 2024

Hmm, I'm not sure what's happening here. Everything looks OK to me in the code you've shown. (And it's a clever way to convert Mailgun special headers from your existing code into SES params.)

Your shell example shows the SESv2 client was created successfully and does have a send_email function as expected. (<bound method ... of <botocore.client.SESV2 object ...>> is the correct value for c.client.send_email. In the shell, you could call it using c.client.send_email(params...).)

Some ideas to check:

  • Is there any reason your shell test could be different from the environment where you're getting the error? Maybe different boto3 credentials or region?

  • Is there any other code in your custom SESBackend? (Anything that might be altering its client attribute?)

  • Does this happen on every attempt to send, or do some sends work? Has this worked before and is broken now, or is this new code? (Standard debugging questions—apologies if you've already worked through this.)

To get more info, you might try wrapping the post_to_esp method to capture more info—in particular, what's actually in self.client at the time:

class SESBackend(AnymailBackend):
    def post_to_esp(self, payload, message):
        try:
            getattr(self.client, payload.api_name)
        except AttributeError:
            # Include repr(self.client) in the error message:
            raise NotImplementedError(
                f"{self.client!r} does not have attr {payload.api_name!r}."
            ) from None
        return super().post_to_esp(payload, message)

    def build_message_payload(self, message: Any, defaults: Any) -> Any:
        ...

If self.client ends up being None—or anything other than a botocore.client.SESV2 object—that might suggest some other places to look.


Btw (unrelated to your issue), you can supply the SES ConfigurationSetName directly in your settings.py ANYMAIL dict if you prefer, rather than using esp_extra (docs):

ANYMAIL = {
    ...,
    "AMAZON_SES_CONFIGURATION_SET_NAME": "<name>",
}

from django-anymail.

medmunds avatar medmunds commented on September 22, 2024

@andraantariksa any more info on this? As I said earlier, I don't see any explanation for the error you saw in the code you included, and your Django shell test seems to show it's working correctly.

from django-anymail.

andraantariksa avatar andraantariksa commented on September 22, 2024

Sorry, I still can't reproduce the issue ☹️ .

from django-anymail.

medmunds avatar medmunds commented on September 22, 2024

I'm guessing maybe you were running with an older version of django-anymail in the environment where the error occurred, and had some problem with your boto3 credentials. That would make this a duplicate of #308. (Or perhaps you were running with an older version of boto3 that didn't support SES v2, which could cause a similar error.)

If you see the problem again and can provide more info, please add it here and I'll reopen the issue.

from django-anymail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.