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
  UserMailer.account_activation(@user).deliver_now
  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'],
  domain: ENV['MAILGUN_DOMAIN']
}

config.action_mailer.perform_caching = false

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

MAILGUN_API_KEY=key-<<KEY>>
MAILGUN_DOMAIN=mg.<<MYDOMAIN>>.nl

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?

EDIT

I forgot to include my terminal trace:

Started POST "/signup" for 127.0.0.1 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;
 boundary="--==_mimepart_59b6ec2f9d9da_4dd63ff8ffd4f034650e4";
 charset=UTF-8
Content-Transfer-Encoding: 7bit


----==_mimepart_59b6ec2f9d9da_4dd63ff8ffd4f034650e4
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

Hi Mailtest,

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

<<ACTIVATION LINK>>


----==_mimepart_59b6ec2f9d9da_4dd63ff8ffd4f034650e4
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

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

  <body>
    <h1><<DOMAIN>></h1>

<p>Hi Mailtest,</p>

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

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

  </body>
</html>

----==_mimepart_59b6ec2f9d9da_4dd63ff8ffd4f034650e4--

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

...