ActionMailer dont function with JRuby?

I have application that i send email normal with native ruby.

But when i execute the sample application with jruby, it dont send email and dont get error.

What can be wrong?

In your config/environments/development.rb, have you configured things properly for ActionMailer ?

What is your config for config.action_mailer.raise_delivery_errors ? it should be set to true for it to report errors.

You will have to give more details regarding your mail server as well…

Thanks & Regards,
Dhruva Sagar.

Im using the normal configuration in “/config/environment.rb”:

Configuração do smtp

ActionMailer::Base.default_content_type = ‘text/html’
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:tls => true,
:address => ‘smtp.gmail.com’,
:port => 587,
:domain => ‘mydomain.com’,
:authentication => :plain, # pode usar também :login
:user_name => ‘my_email’,
:password => ‘my_pass’
}

When i change to show erros from action mailer, i get:

wrong # of arguments(3 for 2)
D:/www/teste_235/vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:33:in check_auth_args' D:/www/teste_235/vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:33:in do_tls_start’
D:/www/teste_235/vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:18:in start' D:/www/teste_235/vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb:10:in start’
D:/www/teste_235/vendor/plugins/action_mailer_optional_tls/lib/action_mailer_tls.rb:9:in perform_delivery_smtp' D:/www/teste_235/vendor/rails/actionmailer/lib/action_mailer/base.rb:523:in deliver!’
D:/www/teste_235/vendor/rails/actionmailer/lib/action_mailer/base.rb:395:in method_missing' D:/www/teste_235/app/models/job_teste.rb:7:in perform’
D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:217:in invoke_job' D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:92:in run_with_lock’
D:/Servidor/jruby/lib/ruby/1.8/benchmark.rb:308:in realtime' D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:91:in run_with_lock’
D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:155:in reserve_and_run_one_job' D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:154:in each’
D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:154:in reserve_and_run_one_job' D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:201:in work_off’
D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:200:in times' D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/job.rb:200:in work_off’
D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/worker.rb:28:in start' D:/Servidor/jruby/lib/ruby/1.8/benchmark.rb:308:in realtime’
D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/worker.rb:27:in start' D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/worker.rb:24:in loop’
D:/www/teste_235/vendor/plugins/delayed_job/lib/delayed/worker.rb:24:in start' D:/www/teste_235/vendor/plugins/delayed_job/tasks/tasks.rb:13 D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain’
D:/Servidor/jruby/lib/ruby/1.8/monitor.rb:242:in mon_synchronize' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run’
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
D:/Servidor/jruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:19:in `load’
D:/Servidor/jruby/bin/rake:19

Ahhh so you require TLS :).

Well firstly you want to add the config I mentioned in the previous email here so that it logs errors for you.

Regarding TLS, can you tell me what rails version & ruby version are you using ?

If your using Ruby version 1.8.x then it turns out that ActionMailer is not working properly with TLS.

There are a few hacks available for the same, you have to download a file tls_smtp.rb. Please google and find for that, you should find it easily, I forgot the source and unfortunately the file doesn’t mention the author / source as comments.

My configuration is like this now for TLS :

# In the development environment your application’s code is reloaded on

# every request. This slows down response time but is perfect for development

# since you don’t have to restart the webserver when you make code changes.

config.cache_classes = false

# Log error messages when you accidentally call methods on nil.

config.whiny_nils = true

# Show full error reports and disable caching

config.action_controller.consider_all_requests_local = true

config.action_view.debug_rjs = true

config.action_controller.perform_caching = false

# Don’t care if the mailer can’t send

config.action_mailer.raise_delivery_errors = true

require 'tls_smtp’

ActionMailer::Base.perform_deliveries = true

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {

:address => ‘gmail.com’,

:port => 447,

:domain => ‘gmail.com’,

:authentication => :login,

:user_name => ‘dhruva.sagar@gmail.com’,

:password => ‘password_goes_here’,

:ssl => true

}

These are my configurations

Thanks & Regards,
Dhruva Sagar.

Thx for response.

But im already have this file “smtp_tls.rb”, im using a plugin called: “action_mailer_optional_tls”

With normal ruby(native) it run OK, but only when i use jruby it dont send.

Im using ruby 1.8.7(come with jruby) and rails 2.3.5

Ty again.

I had tried the same plugin as well, but I couldn’t get it working for some reason, since I had a short deadline at that time, I didn’t investigate much, for me having the tls_smtp.rb file inside lib folder and having a require statement worked… Hopefully someone else would have more clarity on the same.

Thanks & Regards,
Dhruva Sagar.

Yeah. I try copy only the tls_smtp.rb to lib, but i got the same problem.

Im searching for it on google, but i found only people with the same problem.

If anyone can help or know a solution, please post here :frowning: