Mailgun.js throws unauthorized 401 MailgunAPIError

106 Views Asked by At

I'm trying to implement sending newsletter emails for my blog. I follow this article Guide except I use Sanity instead of Storyblok.

I managed to verify my domain, trigger Sanity webhook to make POST request, add subscribers' emails to Mailing list but somehow encounter 401 error while trying to send newsletter.

What I have tried:

  • Switching url parameter from default to 'https://api.eu.mailgun.net'

  • Switching from my domain to Mailgun sandbox domain.

  • Switching between Domain Sending API key and Mailgun API key

  • Adding ngrok Web Interface to Mailgun's IP Access Management

  • Adding 'key' to key parameter e.g: key: key-${process.env.MAILGUN_API_KEY}

  • Adding prefix NEXT_PUBLIC to enviroment variables e.g: NEXT_PUBLIC_MAILGUN_API_KEY

  • Install dotenv package

What I think could cause the error: my domain is registered in Vietnam with ending .vn

0

There are 0 best solutions below