1

I am trying to test my setup for Anymail (using Mailgun) webhooks. Currently using https://ngrok.com/ which redirects an HTTPS address to a local address to properly handle localhost:80 addresses.

Mailgun allows to send test requests to a webhook, which points to the temporary ngrok provided addres, something like:

https://random:random@somthing.ngrok.io/webhooks/anymail/mailgun/tracking/

Following anymail-webhooks the app is currently able to actually receive the webhook call as shown in the logs:

web          | "POST /webhooks/anymail/mailgun/tracking/ HTTP/1.1" 200 0

The response code 200 indicates the backend received the webhook correctly and sent an acknowdledge.

The url is set here:

path('webhooks/anymail/', include('anymail.urls')),

and the signal receiver is as simple as:

from anymail.signals import tracking
from django.dispatch import receiver

@receiver(tracking)
def handle_signal(sender, event, esp_name, **kwargs):
    print('[ --- ] {}'.format(event))

I expect to see something in my shell for every POST to /webhooks/anymail/mailgun/tracking/ but apparently the receiver is never receiving the signal and thus not printing anything.

I went over this a couple of times and I can't figure what am I missing.

PepperoniPizza
  • 8,842
  • 9
  • 58
  • 100
  • Where in your project have you put the code that listens for the `tracking` signal? – solarissmoke Jun 25 '18 at 04:59
  • 1
    And following on @solarissmoke's question, is the file with your `handle_signal` receiver actually imported by some other file in your project? Try logging something like `print('signal handler loaded')` at the root of your signal handler file to make sure it's getting loaded. If not, see (e.g.) [this answer](https://stackoverflow.com/a/28135149/647002). – medmunds Jun 25 '18 at 21:04

0 Answers0