765: unexpected token at 'Mailgun Magnificent API' (Ruby on Rails, mailgun_rails)

0 votes
asked Sep 11, 2017 by finn

I've been trying to set up the mailgun API with my rails app (in development) and I'm using the mailgun_rails gem, but when trying to send a message the Action Controller gives me an error:

JSON::ParserError in UsersController#create

765: unexpected token at 'Mailgun Magnificent API'

The extracted source is as follows:

@user = User.create(user_params)
if @user.save
  flash[:info] = "Please check your email to activate your account."
  redirect_to root_url

my development.rb has the following lines concerning the action mailer:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :mailgun

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.perform_deliveries = true

config.action_mailer.mailgun_settings = {
  api_key: ENV['MAILGUN_API_KEY'],

config.action_mailer.perform_caching = false

The environments in my .rbenv-vars file look like this:


All Domain verifications & DNS for mailgun have been completed (and recognized my mailgun itself).

Could anyone please help me figure out what's going wrong?


I forgot to include my terminal trace:

Started POST "/signup" for at 2017-09-11 22:03:58 +0200
  ActiveRecord::SchemaMigration Load (0.3ms)  SELECT `schema_migrations`.* FROM `schema_migrations`
Processing by UsersController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"<<TOKEN>>", "user"=>{"name"=>"Mailtest", "email"=>"<<EMAIL>>", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
   (0.2ms)  BEGIN
  User Exists (0.3ms)  SELECT  1 AS one FROM `users` WHERE `users`.`email` = '<<EMAIL>>' LIMIT 1
  SQL (0.3ms)  INSERT INTO `users` (`email`, `name`, `created_at`, `updated_at`, `password_digest`, `activation_digest`) VALUES ('<<EMAIL>>', 'Mailtest', '2017-09-11 20:03:59', '2017-09-11 20:03:59', '<<TOKEN>>', '<<TOKEN>>')
   (1.9ms)  COMMIT
   (0.2ms)  BEGIN
  User Exists (0.3ms)  SELECT  1 AS one FROM `users` WHERE `users`.`email` = '<<EMAIL>>' AND (`users`.`id` != 17) LIMIT 1
   (0.2ms)  COMMIT
  Rendering user_mailer/account_activation.html.erb within layouts/mailer
  Rendered user_mailer/account_activation.html.erb within layouts/mailer (5.6ms)
  Rendering user_mailer/account_activation.text.erb within layouts/mailer
  Rendered user_mailer/account_activation.text.erb within layouts/mailer (0.6ms)
UserMailer#account_activation: processed outbound mail in 222.3ms
Sent mail to <<EMAIL>> (1149.7ms)
Date: Mon, 11 Sep 2017 22:03:59 +0200
From: noreply@<<DOMAIN>>.nl
To: <<EMAIL>>
Message-ID: <<ID>>
Subject: Account activation
Mime-Version: 1.0
Content-Type: multipart/alternative;
Content-Transfer-Encoding: 7bit

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

Hi Mailtest,

Welcome to the <<DOMAIN>>! Click on the link below to activate your account:


Content-Type: text/html;
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      /* Email styles need to be inline */


<p>Hi Mailtest,</p>

Welcome to the <<DOMAIN>>! Click on the link below to activate your account:

<a href="<<ACTIVATION LINK>>">Activate</a>



Completed 500 Internal Server Error in 1589ms (ActiveRecord: 5.4ms)

JSON::ParserError (765: unexpected token at 'Mailgun Magnificent API')

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter