Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token at 'Mailgun Magnificent API' #77

Open
btkramm opened this issue Jun 24, 2017 · 6 comments
Open

Unexpected token at 'Mailgun Magnificent API' #77

btkramm opened this issue Jun 24, 2017 · 6 comments

Comments

@btkramm
Copy link

btkramm commented Jun 24, 2017

Hi! I can send emails in my development environment but I can't in production. I'm getting the error: "765: unexpected token at 'Mailgun Magnificent API'"

@rkapil12
Copy link

can you paste your request url, that might be the reason I guess, you migt have missed messages https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages

@jeffb5000
Copy link

jeffb5000 commented Aug 27, 2017

@rkapil12 Doesn't mailgun_rails already do that? In lib/mailgun_rails/client.rb the send_message function uses the mailgun_url which is an api_url of "https://api:#{api_key}@api.mailgun.net/v3/#{domain}" + "/messages"

Edit: In testing with postman against mailgun's api, I can get it to return 'Mailgun Magnificent API' if I leave off the /messages from the url. My understanding though is that mailgun_rails is adding /message to whatever url is entered as the domain in the config file.

@thomas07vt
Copy link

So I am not sure if this fixes your issue @btkramm , but I had the same error when I was using an incorrect domain. The documentation is a little ambiguous:

config.action_mailer.delivery_method = :mailgun
config.action_mailer.mailgun_settings = {
  api_key: '<mailgun api key>',
  domain: '<mailgun domain>'
}

The "mailgun_domain" is the domain name that you register with mailgun. Let's say you registered mailgunrailsrocks.com and link it to your mailgun account. You will see something like this in your mailgun dashboard;

State Active
IP Address 127.0.0.1
SMTP Hostname smtp.mailgun.org
Default SMTP [email protected]
API Base URL https://api.mailgun.net/v3/mailgunrailsrocks.com
API Key key-abcxyz

you should NOT use https://api.mailgun.net/v3/mailgunrailsrocks.com/messages instead use the literal domain of mailgunrailsrocks.com in your config

so it will look like this:

config.action_mailer.delivery_method = :mailgun
config.action_mailer.mailgun_settings = {
  api_key: 'key-abcxyz',
  domain: 'mailgunrailsrocks.com'
}

@AlexAvlonitis
Copy link

Had the same issue on production. Restarting my server solved it. My guess is caching issues, and instead of pinpointing what was stale (DNS, ENVs etc...), i just restarted the whole thing.

@ricardovanlaarhoven
Copy link

Ever found a solution?

@nafaabout
Copy link

nafaabout commented Jan 29, 2019

Had the same issue. It turns out I forget to source the file where the api key and domain are exported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants