Sending mail in Redmine - ruby-on-rails

I have updated my Remine on servers from 2.3.0 to 2.4.1 and one (and only one of them) stops sending mail. If I was switched it back to 2.3.0 version, all works fine.
I am going to try to debug the code and just wondering which file in source code will be a good starting point to it ?
I have found notified_users(), recipients(), each_notification() in Issue model, but where is a code line which send email ?
Updated:
When I edit issue I get next message on console:
Rendered mailer/_issue.html.erb (2.2ms)
Rendered mailer/issue_edit.html.erb within layouts/mailer (4.8ms)
Sent email "[Redmine - ÐапÑÐ¾Ñ #13757] test" (26ms)
to: mymail#gmcs.ru
Date: Thu, 05 Dec 2013 17:34:07 +0400
....
cG9ydC5nbWNzLnJ1L215L2FjY291bnQ8L2E+PC9wPjwvc3Bhbj4KPC9ib2R5
Pgo8L2h0bWw+Cg==
----==_mimepart_52a080cfa4564_af93f8d53ef7714733eb--
Email delivery error: wrong argument (NilClass)! (Expected kind of OpenSSL::SSL::SSLContext)
(5.9ms) COMMIT
Redirected to http://vm-mecomstracker:90/issues/13757
Completed 302 Found in 574.3ms (ActiveRecord: 33.5ms)

I think you should look at app/models/mailer.
For example notified_users is used here
If update breaks sending emails I suggest to review config files, for example config/configuration.yml.example and check fresh issues on redmine.org

Related

Rails/Sendgrid Error: getaddrinfo: name or service not known

I've all of a sudden started getting this error when creating users in my app. Emails were working before I left for vacation, now I come back and this is what my tech support gives me! Ugh.
So, I make a user, and I get redirected to my admin panel with the following error in a flash notice: getaddrinfo: name or service not known. The user isn't created.
Looking at the logs, it looks like everything worked fine:
I, [2016-04-12T08:01:52.089647 #11555] INFO -- : Started POST "/admin/user/new" for 72.238.202.193 at 2016-04-12 08:01:52 -0500
I, [2016-04-12T08:01:52.092114 #11555] INFO -- : Processing by RailsAdmin::MainController#new as HTML
I, [2016-04-12T08:01:52.092259 #11555] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"vxhuTwXhQo6nYrskQcYH9W56Ej95LgzEbs8cnkjXQI4=", "user"=>{"company_id"=>"35", "username"=>"myuser#thedomain.com", "first_name"=>"Test", "last_name"=>"User", "full_name"=>"Test User", "time_zone"=>"Central Time (US & Canada)", "email"=>"myuser#thedomain.com", "phone_number"=>"", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "reset_password_sent_at"=>"[FILTERED]", "remember_created_at"=>"", "sign_in_count"=>"0", "current_sign_in_at"=>"", "last_sign_in_at"=>"", "current_sign_in_ip"=>"", "last_sign_in_ip"=>"", "authentication_token"=>"", "enable_notifications"=>"1", "confirmation_token"=>"MBrmpsD6Wtf1VBrhtDyc", "confirmed_at"=>"", "confirmation_sent_at"=>"April 12, 2016 10:00", "unconfirmed_email"=>"myuser#thedomain.com", "terms_accepted"=>"1", "cancel_subscription"=>"0", "on_trial"=>"0", "is_account_owner"=>"1", "role_ids"=>["", "", "2"]}, "return_to"=>"https://www.myserver.com/admin/user?sort=created_at&sort_reverse=false", "_save"=>"", "model_name"=>"user"}
I, [2016-04-12T08:01:52.212064 #11555] INFO -- : Rendered devise/mailer/confirmation_instructions.html.erb (1.6ms)
I, [2016-04-12T08:01:52.340343 #11555] INFO -- :
Sent mail to myuser#thedomain.com (9.3ms)
I've filtered the email address but, rest assured, it's a valid email.
I'm using EC2 to host my application, so I can't edit /etc/resolv.conf since any changes will be overridden.
I've run nslookup to make sure the server can find the domain MX records, which it does using the nameserver specified in /etc/resolv.conf.
What else can I do to troubleshoot this issue?
I used a recommendation I ran across on another blog to use Ruby's version of Resolv instead of the libc library with Ubuntu. So, I added the following line to an initializer: require resolv-replace.rb.
Now my error is a little more descriptive: Hostname not known: smtp.sendgrid.net, so I checked config/environments/production.rb and it turns out I had a trailing space at the end of my host line. Removed it and all is working now!

Rails production.log (using Passenger) being written to by multiple processes, can't be parsed

Here's a snippet of my production.log:
Started GET "/product/514034/754240" for XX.XX.202.138 at 2012-06-21 11:52:28 -0700
Started GET "/product/614409/666897" for XX.XX.228.38 at 2012-06-21 11:52:28 -0700
Processing by ProductsController#show as HTML
Parameters: {"category_id"=>"514034", "product_id"=>"754240"}
Processing by ProductsController#show as HTML
Parameters: {"category_id"=>"614409", "product_id"=>"666897"}
Logged in 2940659 via auth cookie
Logged in 585210 via auth cookie
[e3e3fc56bb6bd137741b269ee397683c] [2940659] Read fragment views/global-caches/header (0.7ms)
[e3e3fc56bb6bd137741b269ee397683c] [2940659] Rendered shared/_email_form.html.haml (0.7ms)
[d81bb986be5acc0277c0c9e11b414249] [585210] Read fragment views/global-caches/sharebar-message (0.7ms)
[d81bb986be5acc0277c0c9e11b414249] [585210] Rendered shared/_email_form.html.haml (0.7ms)
...
As you can see, it's logging two concurrent sessions of two different users simultaneously to the same log file. This makes it impossible to parse my logs and determine, for example, the time it took to generate each kind of page, because the entries are not in the expected order of:
Started GET "/URL/BLAH" for IP at DATE
... stuff...
Completed 200 OK in XXms (ActiveRecord: YY.Yms)
Instead I get an unpredictable interleaved log like this:
Started GET "/URL/BLAH" for IP at DATE
Started GET "/URL/BLAH" for IP at DATE
... stuff...
Completed 200 OK in XXms (ActiveRecord: YY.Yms)
...stuff...
Completed 200 OK in XXms (ActiveRecord: YY.Yms)
So it's impossible to match the "completeds" with the "Started."
What I'd like is a way to have each child process write to its own log or something. Or if it's possible a way to write the each pageview's log atomically, but that might be impossible or difficult or hurt performance.
Rails 3.2 provides nice option config.log_tag
You can add to your production.rb:
config.log_tags = [ lambda { Time.now.to_i }]
So each line in your logs will be prepended by numbers. Example:
[1351867173] Started GET "/" for 127.0.0.1 at 2012-11-02 16:39:33 +0200
[1351867173] Processing by RecipesController#main as HTML
Logs are still shuffled, but now we can normalize, order them.
sort -f -s -k1.1,1.11 production.log | sed 's/^.............//' > sorted_production.log
(Sorter by first symbols (by timestamp) and remove timestamp by sed)
Now logs are easy to analyze.
In addition there is fix on related issue https://github.com/rails/rails/pull/7317 in rails 3.2.9
So keep this in mind.
Sorry for bad English... )

link_to :remote => :true fails in IE

I'm having a problem with remote links in IE, and I need to get it up & running soon cause the deadline is today :S
The problem is that we're using AJAX to make a remote call to an action and eval the returned javascript.
When making the call using Firefox for example it's working fine, if I do it in IE, the response is made as HTML request.
IE entry in development log
Started GET "/semantic/country/5" for 127.0.0.1 at Wed Sep 07 12:06:00
+0200 2011 Processing by Semantic::SemanticController#country as HTML
Parameters: {"id"=>"5"} Country Load (1.0ms) SELECT countries.*
FROM countries WHERE countries.id = 5 LIMIT 1 Rendered
semantic/semantic/country.js.erb (1.0ms) Completed 200 OK in 1785ms
(Views: 54.0ms | ActiveRecord: 1.0ms)
Firefox call in development log
Started GET "/semantic/country/5" for 127.0.0.1 at Wed Sep 07 12:06:00
+0200 2011 Processing by Semantic::SemanticController#country as JS
Parameters: {"id"=>"5"} Country Load (1.0ms) SELECT countries.*
FROM countries WHERE countries.id = 5 LIMIT 1 Rendered
semantic/semantic/country.js.erb (1.0ms) Completed 200 OK in 1785ms
(Views: 54.0ms | ActiveRecord: 1.0ms)
The code used to generate the link is the following (in HAML):
link_to #vacancy.country.name, semantic_country_url(#vacancy.country.id), {:remote => true, :class => 'ajax'}
The problem seems to be how IE interprets the data-remote stuff in the HTML5. Is there a solution around this?
without switching to jquery, beause I cannot rewrite all the javascript in the application.
EDIT
Found out that the IE browser sends the request twice now,first time a JS, which works fine, but second time as HTML.
don't run firebug AND IEdevtools at the same time...They both respond to the feedback messages and start acting weird in this case.
Once I shut down Firebug IE worked fine.

objects that are not created show on the page, and redirect fails

I tried out rails 3, and just started a new project. The following is all I typed.
rails new todo
cd todo
bundle install
rails generate scaffold Task done:boolean task:text created:date
rake db:migrate
rails server&
firefox 0.0.0:3000/tasks&
On page 0.0.0:3000/tasks/new, I filled in some values for the fields, and clicked the button to create a new task. It redirects to 0.0.0:3000/tasks with a blank page. When I manually reload the page, it shows up eight tasks even though there is supposed to be only one.
When I further click either show, edit, or destroy, it says, for e.g.: ActiveRecord::RecordNotFound in TasksController#show Couldn't find Task with ID=1.
When I reload to 0.0.0:3000/tasks, all eight tasks are still there.
What is wrong with this? Is rails corrupted on my computer?
Log
When I click 'create tasks', the terminal displays
Started GET "/tasks/new" for 127.0.0.1
at 2011-05-13 22:04:26 -0400
Processing by TasksController#new as
HTML Rendered tasks/_form.html.erb
(6.7ms) Rendered tasks/new.html.erb
within layouts/application (25.3ms)
Completed 200 OK in 35ms (Views:
27.9ms | ActiveRecord: 0.0ms)
folowed by something like this repeated eight times with x in tasks/x varying from 1 to 8:
Started POST "/tasks" for 127.0.0.1 at
2011-05-13 22:04:32 -0400 Processing
by TasksController#create as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"QZHWWyE5KcZhLrzRhB4Fgnl9HGiQqNkn17O4CUfUUJU=",
"task"=>{"done"=>"0",
"task"=>"test\r\n",
"created(1i)"=>"2011",
"created(2i)"=>"5",
"created(3i)"=>"14"},
"commit"=>"Create Task"} AREL
(0.2ms) INSERT INTO "tasks" ("done",
"task", "created", "created_at",
"updated_at") VALUES ('f', 'test ',
'2011-05-14', '2011-05-14
02:04:32.065805', '2011-05-14
02:04:32.065805') Redirected to
http://0.0.0:3000/tasks/2 Completed
302 Found in 17ms [2011-05-13
22:04:32] ERROR URI::InvalidURIError:
the scheme http does not accept
registry part: 0.0.0:3000 (or bad
hostname?)
/usr/local/lib/ruby/1.9.1/uri/generic.rb:746:in
rescue in merge'
/usr/local/lib/ruby/1.9.1/uri/generic.rb:743:in
merge'
/usr/local/lib/ruby/1.9.1/webrick/httpresponse.rb:163:in
setup_header'
/usr/local/lib/ruby/1.9.1/webrick/httpresponse.rb:101:in
send_response'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:86:in
run'
/usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in
block in start_thread'
You're trying to access your site using 0.0.0:3000 which is an invalid address (I'm actually surprised this even gives you access to the site at all).
Open 0.0.0.0:3000 in Firefox instead, and it will work perfectly!
(You can also use localhost:3000 or 127.0.0.1:3000)
Task is a reserved word in Rails. I guess thats the reason why rails is behaving in a starnge way.
For a list of other reserved words please refer to any of these links
http://cheat.errtheblog.com/s/rails_reserved_words/
http://www.yup.com/articles/2007/01/31/no-reservations-about-keywords-in-ruby-on-rails
http://oldwiki.rubyonrails.org/rails/pages/ReservedWords

Getting error 406 from Facebooker API on Rails 2.3?

My app was working fine with Rails 2.2 and Facebooker 1.0.13, but I keep getting a 406 error with Rails 2.3.
I checked the mime type, canvas/iframe setting in Facebook, and the requests work fine outside of Facebook (i.e. I get the full app as long as I'm not accessing it within the Facebook iframe). Has something changed recently in the Facebook API that would cause this error? Or is there anything in Facebooker that you've found might be fixed quickly?
Here is my Dev log for reference:
Processing PostsController#index (for xx.xxx.xx.xxx at 2009-03-06 03:24:44) [GET]
Parameters: {"fb_sig_app_id"=>"xxxxx",
"fb_sig_in_iframe"=>"1",
"fb_sig_locale"=>"en_US",
"fb_sig_in_new_facebook"=>"1",
"fb_sig"=>"xxxxx",
"fb_sig_added"=>"1",
"fb_sig_expires"=>"xxxxx",
"fb_sig_session_key"=>"xxxxx",
"fb_sig_ss"=>"xxxxx",
"fb_sig_api_key"=>"xxxxx",
"fb_sig_time"=>"1236327886.7997",
"fb_sig_profile_update_time"=>"1228275036",
"fb_sig_user"=>"11111"}
User Columns (6.0ms) SHOW FIELDS FROM users
User Load (1.0ms) SELECT * FROM users WHERE (users.login = 11111) LIMIT 1
SQL (0.0ms) BEGIN
SQL (0.0ms) COMMIT
Competition Load (0.0ms) SELECT * FROM posts
Completed in 135ms (View: 8, DB: 8) | 406 Not Acceptable
[http://xx.xx.xxx.xxx/?fb_sig_in_iframe=1&
fb_sig_locale=en_US&
fb_sig_in_new_facebook=1&
fb_sig_time=xxxxx.xxxxx&
fb_sig_added=1&
fb_sig_profile_update_time=1228275036&
fb_sig_expires=xxxxx&
fb_sig_user=xxxxx&
...]
If more details are needed, I'll be glad to give them...:-)
Found the answer in the Facebook Forums:
http://forum.developers.facebook.com/viewtopic.php?pid=93648#p93648
Sorry for implying that Facebooker wasn't working correctly...What you're doing is GREAT Michael (et al), keep up the great work!

Resources