2

I've set up rails application to receive mails and create bookmarks from. Herefore I included the gem 'mailgun'. Because its not working correctly however I want to use runscope to get a better insight on which data is sent.

I've done the following steps in my application: 1. Added mailgun to heroku 2. Set up an initializer

ActionMailer::Base.smtp_settings = {
 port:              587, 
 address:           'smtp.mailgun.org',
 user_name:         ENV['MAILGUN_SMTP_LOGIN'],
 password:          ENV['MAILGUN_SMTP_PASSWORD'],
 domain:            'appurlhere.com',
 authentication:    :plain,
 content_type:      'text/html' 
}
ActionMailer::Base.delivery_method = :smtp

# Makes debugging *way* easier. 
ActionMailer::Base.raise_delivery_errors = true
  1. Set up a route for incoming

    post :incoming, to: 'incoming#create'

  2. Created the incoming controller

    def create
     @user = User.find_by_email(params[:sender])
     @topic = @user.topics.find_by(title: params[:subject])
     @url = "http://#{params["body-plain"]}"
    
     @user = User.create(email: params[:sender], password: "#{params[:subject]}") if @user.nil?
     @topic = Topic.create(title: params[:subject], user_id: @user.id) if @topic.nil?
     @bookmark = Bookmark.create(topic_id: @topic, user_id: @user, url: "what should be here")
     head 200
    end
    

But now I don't get where I should adjust code so I can see better data (and debug) better. I tried adding code to my routes in mailgun but that didn't work.

Alvaro Montoro
  • 28,081
  • 7
  • 57
  • 86
user3706202
  • 197
  • 1
  • 3
  • 14
  • What part are you trying to debug? Outgoing API calls to Mailgun or external calls being made to your rails app? If the former, you can monkey patch mailgun gem, changing the hostname from api.mailgun.com to api-mailgun-com-RUNSCOPEBUCKETKEY.runscope.in. – mansilladev Mar 05 '15 at 16:43
  • Sorry, that should have been runscope.net – mansilladev Mar 05 '15 at 22:19

0 Answers0