Defect #13698

Wrong argument error when sending email notifications after upgrading to 2.3.0

Added by Mike Johnson over 4 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email notifications
Target version:-
Resolution:Invalid Affected version:2.3.0

Description

Email notifications were working yesterday. I upgraded to Redmine 2.3.0 last night, and today I noticed email notifications weren't being sent out. I tried to send a test email and received the following error message:

An error occurred while sending mail (wrong argument (Fixnum)! (Expected kind of OpenSSL::SSL::SSLContext))

I checked my configuration.yml to make sure it was copied over from the earlier version (2.1.2), and it was:

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: ourdomain.mail.eo.outlook.com
      port: 25
      domain: redmine.ourdomain.com

I have tried changing the delivery method to async_smtp but received the same error message. As you can see from the configuration, there is no SSL/TLS and no authentication. I also tried changing the domain name to a non-existant name, and received the same error.

Here is my environment information:

Server OS: FreeBSD 9.
Redmine version: 2.3.0.stable
Ruby version: 1.8.7 (amd64-freebsd9)
Rails version: 3.2.13
Environment: production
Database adapter: MySQL

Firefox.png (12.1 KB) Sebastián Moreno, 2013-04-11 16:19


Related issues

Related to Redmine - Defect #14174: email sendding problem when update 2.2.3 to 2.3.1 and 2.3... Closed
Related to Redmine - Defect #15775: Email delivery error: wrong argument (Fixnum)! (Expected ... Closed

History

#1 Updated by Mike Johnson over 4 years ago

  • Status changed from New to Resolved

This just started working on it's own somehow. I have no idea what the problem was :(

#2 Updated by Toshi MARUYAMA over 4 years ago

  • Status changed from Resolved to Closed

Thank you for your feedback.

#3 Updated by Sebastián Moreno over 4 years ago

Hey guys, I'm running on the exact same problem. I upgraded to 2.3.0 and mail just stopped working.

Email Configuration:

default:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: mail.domain.com
port: 25
domain: "domain.com"
authentication: :login
user_name: "no-reply@domain"
openssl_verify_mode: "none"

I don't even know were to look. :(

Server OS: Debian Squeeze 6.0.6.
Redmine version: 2.3.0.stable
Ruby version: ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
Rails version: 3.2.13
Environment: production
Database adapter: MySQL

Thanks!

#4 Updated by Toshi MARUYAMA over 4 years ago

  • Status changed from Closed to Reopened

#5 Updated by Sebastián Moreno over 4 years ago

There is anything I can do to give you more information? Some kind of log or something?

#6 Updated by Etienne Massip over 4 years ago

Try sending a test email from Administration/Settings tab and have a lokk to your production.log contents.

#7 Updated by Sebastián Moreno over 4 years ago

Ok, I did it, but there is nothing related to the send mail error, just the rendering of the page and sql queries.

#8 Updated by Etienne Massip over 4 years ago

  • Status changed from Reopened to Closed
  • Resolution set to Invalid

Move your settings from the default entry to the production one (at the end of the file).

#9 Updated by Sebastián Moreno over 4 years ago

Changed to this:

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: mail.********..com
      port: 25
      domain: "********..com" 
      authentication: :login
      user_name: "no-reply@********.com" 
      password: "******" 
      openssl_verify_mode: "none" 

Nothing happened, same error.

I don't have any other configuration on the file. If I change (for example the last line: openssl_verify_mode) the error is different (a previous mailer error) so I think it's using correctly the config.

#10 Updated by Toshi MARUYAMA over 4 years ago

  • Status changed from Closed to Reopened

#11 Updated by Toshi MARUYAMA over 4 years ago

  • Resolution deleted (Invalid)

#13 Updated by Etienne Massip over 4 years ago

I think Toshi is right, I didn't see your screenshot in the first place.

#14 Updated by Sebastián Moreno over 4 years ago

Perfect! It works! Thanks a lot guys :)

#15 Updated by Etienne Massip over 4 years ago

  • Status changed from Reopened to Closed
  • Resolution set to Invalid

#16 Updated by Jorge Cabrera over 4 years ago

Hi, I'm having the same problem after upgrading to 2.3.1. Toshi's solution didn't work on my case because Exchange Online requires TLS. I opened an issue with this (#37885). Can someone please guide me on how to solve this problem? My configuration is this:

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: "pod51016.outlook.com" 
      port: '587'
      authentication: :login
      user_name: "theuser@thedomain" 
      password: "thepassword" 

#17 Updated by Jean-Philippe Lang over 4 years ago

First, try to remove the quotes around the port then restart Redmine.

#18 Updated by Artur Smolarek over 4 years ago

I can confirm Jorge's problem. I have already updated Redmine to 2.3.1.

My e-mail configuration looks like:

default:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: "xyz.com" 
      port: 587
      authentication: :login
      user_name: "user@xyz.com" 
      password: "mypasswd" 
      enable_starttls_auto: true

Output of the mail test:

An error occurred while sending mail (wrong argument (NilClass)! (Expected kind of OpenSSL::SSL::SSLContext))

I tried also to install "always_verify_ssl_certificates" gem but without any positive results.

Any idea?

#19 Updated by Rodrigo Braz over 4 years ago

I still have the same problem as above, no recommended fix worked.
Stopped working after the update to 2.3, and I'm using settings for a google apps email.

I think it has something to do with the openssl_verify_mode property. I have it set to

openssl_verify_mode: 'none'

but if I remove the line the error changes to wrong argument (NilClass) instead of (FixNum).

#20 Updated by BTR Naidu over 4 years ago

Same error here. Any more ideas guys?

#21 Updated by Oscar Moncada over 4 years ago

I'm having a similar issue, just updated to version 2.3.1 and I can't get the notification emails to work.

I get the following error:

An error occurred while sending mail (wrong argument (NilClass)! (Expected kind of OpenSSL::SSL::SSLContext))

This is my configuration:

production:
   email_delivery:
     delivery_method: :smtp
     smtp_settings:
       address: smtp.gmail.com
       port: 587
       domain: smtp.gmail.com
       authentication: :plain
       user_name: my.address@my-domain.com
       password: mypassword

This is my redmine environment:

Environment:
  Redmine version                          2.3.1.stable
  Ruby version                             1.8.7 (x86_64-linux)
  Rails version                            3.2.13
  Environment                              production
  Database adapter                         Mysql2
Redmine plugins:
  no plugin installed

I've tried everything from switching to async_smtp (which generates a success message but does not send out the email) to setting enable_starttls_auto to false (which generates a different error message that says I must set the starttls first) to using/not using quotes on the username and password parameters, etc. Nothing seems to work :-(

Any help would be greatly appreciated!

#22 Updated by Dmitry Glavchev over 4 years ago

I managed somehow to resolve this for non-SSL/TLS case. Not sure how exactly, I was just playing with config and was going to debug ruby gems responsible for mail delivery but suddenly it just started sending emails. My Redmine is 2.3.1-devel and here is my email config:

default:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: false
      address: smtp.someserver.com
      port: 25
      authentication: :login
      user_name: usernameWithoutQuotes
      password: passwordWithoutQuotes
      openssl_verify_mode: 'none'

Please also note that I've added same email_delivery stuff in production: section in the end of the file configuration.yml.

Certainly some of those configuration settings helped but now I don't want to touch anything :) let it just work.

After changing config restart your Redmine webserver, it looks like ruby scripts can be heavily cached.

#23 Updated by BTR Naidu over 4 years ago

Did you use gmail smtp server? I see you are using port 25. Guess gmail does not use port 25?

#24 Updated by Phuong Tran over 4 years ago

I use sendmail function on CentOS 5.8 final, but I also have the same problem. On setting in Administrator, I used "send test email" And redmine said "sent sucessfull" but I did not receive any email

#25 Updated by BTR Naidu over 4 years ago

Any update guys? Anybody had similar issue before and were able to resolve?

#26 Updated by XDjuj Apsulis over 4 years ago

Like answered before, the fix is here :
- http://www.redmine.org/boards/2/topics/37008

Juste change "openssl_verify_mode 'none'" with "enable_starttls_auto: false" in your config/configuration.xml file.

In my simple case, it now works with :

# default configuration options for all environments
default:
  # Outgoing emails configuration (see examples above)
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: localhost
      port: 25
      domain: mydomain.com           
      enable_starttls_auto: false
     # openssl_verify_mode: 'none' ==> this line is not working anymore on redmine 2.3.x
     # authentication: :login
     # user_name: "redmine@example.net" 
     # password: "redmine" 

  # Absolute path to the directory where attachments are stored.

#27 Updated by Rodrigo Braz over 4 years ago

XDjuj Apsulis wrote:

Like answered before, the fix is here :
- http://www.redmine.org/boards/2/topics/37008

Juste change "openssl_verify_mode 'none'" with "enable_starttls_auto: false" in your config/configuration.xml file.

In my simple case, it now works with :
[...]

This is not a solution. Some email config require tls, which is the case of gmail, so setting it to false won't work anyway.

Removing "openssl_verify_mode" and setting "enable_starttls_auto: true" will give the following error

An error occurred while sending mail (wrong argument (NilClass)! (Expected kind of OpenSSL::SSL::SSLContext))

#28 Updated by Oscar Moncada over 4 years ago

I tried making those changes and still get the same error as before. Has anyone gotten this to work with gmail?

#29 Updated by Peter Panther over 4 years ago

The problem

An error occurred while sending mail (wrong argument (NilClass)! (Expected kind of OpenSSL::SSL::SSLContext))

ist caused by the gem package 'mail' in version 2.5.4 (released on the 14th of may 2013)
(for further details have a look at https://github.com/mikel/mail/issues/548)

All Redmine installations/updates after this date will have the TLS-negotiation problem if ruby 1.8.7 is still used.
Downgrade to version 2.5.3 and TLS-encryption works as before......

#30 Updated by Mikael Nehlsen over 4 years ago

I also have this problem, A small question for a non fluent ruby speaker. how do you downgrade mail I did

gem install mail -v 2.5.3
gem uninstall mail -v 2.5.4

but then I got a nice big error in my redmine installation saying something like this:

Could not find mail-2.5.4 in any of the sources (Bundler::GemNotFound)

#31 Updated by Mikael Nehlsen over 4 years ago

Being impatient I tried some things and found out that what did work was

gem install mail -v 2.5.3

edit the file Gemfile.lock in the redmine root dir update from mail (2.5.4) to mail (2.5.3) and restart in my case apache.

#32 Updated by Oscar Moncada over 4 years ago

Downgrading to mail -v 2.5.3 fixed the issue for me. THANK YOU!!!!

#33 Updated by Phuong Tran over 4 years ago

This solution is not work for me. Downgrading to 2.5.3 the problem is not change. Please view my issue at: http://www.redmine.org/boards/2/topics/37850

#34 Updated by Kuba Zwolinski over 4 years ago

Downgrading mail worked for me, thanks.

#35 Updated by Tomas Latal over 4 years ago

Downgrading to mail 2.5.3 and changing dependency in Gemfile.lock from mail 2.5.4 to 2.5.3 worked for me too. Thank you.

#36 Updated by Christian Rost about 4 years ago

Mikael Nehlsen wrote:

Being impatient I tried some things and found out that what did work was
gem install mail -v 2.5.3
edit the file Gemfile.lock in the redmine root dir update from mail (2.5.4) to mail (2.5.3) and restart in my case apache.

That did it - downgraded mail to 2.5.3; changed mail dependency in Gemfile.lock to 2.5.3; restarted apache; notification mails are sent again. ;-)

#37 Updated by Raphael PRIVAT about 4 years ago

Hello,

I had the same problem with my gmail account and downgrading to 2.5.3 worked.
BUT ... It only works with gmail !

I have a mail server with TLS that I used to access from an older Redmine version (2.1.2 , mail 2.4.4) and everything worked.
Now, with the same configuration.yml (2.3.2, mail 2.5.3 or 2.5.4) it doesn't work.

smtp_settings:
enable_starttls_auto: true
openssl_verify_mode : 'none'
address: "mail.mydomain.com"
port: 587
domain: "mydomain.com"
authentication: :plain
user_name: user@mydomain.com
password: userpass

My certificate is auto signed so I have to set openssl_verify_mode : 'none' and TLS is mandatory.
user and password quoted or unquoted, nothing will do the trick.

Did someone manage to use a TLS account other than GMail ?

#38 Updated by Vladimir Skubriev about 4 years ago

My certificate is auto signed so I have to set openssl_verify_mode : 'none' >and TLS is mandatory.
user and password quoted or unquoted, nothing will do the trick.

I think that it is not ruby mail 2.5.4 problem.

I think that problem is you own Certificate Authority is not trusted by a redmine server system running.

google: update-ca-certificates and other methods to add ca to system store /etc/ssl

#39 Updated by Vladimir Skubriev about 4 years ago

I changed the setting "tls" to false and it worked.

See part of my configuration.yml

# default configuration options for all environments
default:
  # Outgoing emails configuration (see examples above)
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
     tls: false
      enable_starttls_auto: true
      address: "smtp.yandex.ru" 
      port: '587'
      domain: mydomainatyandex.com
      authentication: :plain
      user_name: "user@mydomainatyandex.com" 
      password: "pass" 

Also this work with 2.5.3 and 2.5.4 mail gem version.
I suspect that the port is not significant. You can use 25 or 587 with yandex. With google best way to use 587 port.

#40 Updated by Adrien Crivelli about 4 years ago

Same here, ran sudo gem install mail -v 2.5.3 and edited Gemfile.lock manually to re-enable email notifications.

In my opinion this issue should not be closed until a new mail version is released, which would actually fix the bug.

#41 Updated by Yuri Yurip almost 4 years ago

Hello people,

I will to become crazy with this mail notification !
I always get this error message:

Erreur lors de l'envoi de l'email (wrong argument (NilClass)! (Expected kind of OpenSSL::SSL::SSLContext))

Already try to:

-Downgrade mail version to 2.5.3.
-Change configuration file with different parameters

My config:

Ubuntu 12.x LTS 64 bit under VM

Environment:
Redmine version 2.3.3.stable
Ruby version 1.8.7-p352 (2011-06-30) [x86_64-linux]
Rails version 3.2.13
Environment production
Database adapter MySQL
Redmine plugins:
no plugin installed

My configuration.yml file:

production:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto:false
openssl_verify_mode: 'none'
address: "smtp.gmail.com"
port: '587'
domain: "smtp.gmail.com"
authentication: :plain
user_name: email_name
password: my_password

Any help will be apreciated thank !

#42 Updated by Сергей Нерволь almost 4 years ago

All work fine.

apt-cache policy ruby1.9.3
ruby1.9.3:
Установлен: 1.9.3.0-1ubuntu2.7
Кандидат: 1.9.3.0-1ubuntu2.7

Environment:
Redmine version 2.3.3.stable
Ruby version 1.8.7-p352 (2011-06-30) [x86_64-linux]
Rails version 3.2.13
Environment production
Database adapter PostgreSQL
Redmine plugins:
no plugin installed

My actions to make it works:

  1. Changed Gemfile.lock: changed line mail (2.5.4) --> mail (2.5.3)
  2. gem install mail -v 2.5.3
  3. gem uninstall mail -v 2.5.4
  4. service apache2 restart

cat ./configuration.yml

production:
  delivery_method: :smtp
  smtp_settings:
    enable_starttls_auto: true
    address: smtp.gmail.com
    port: 587
    domain: "my.domain" 
    authentication: :login
    user_name: "robot@my.domain" 
    password: "password" 

#43 Updated by Erlend ter Maat almost 4 years ago

When I downgrade mail to 2.5.3 a dependency for actionmailer breaks.

How can I downgrade "mail" without breaking the dependency?

#44 Updated by Plam Sim almost 4 years ago

Downgrade to 2.5.3 and changing dependencies in "Gemfile.lock" - 2 rows for mail.
However only after implementing the right syntax described in http://www.redmine.org/boards/2/topics/30670 worked for me.
Redmine 2.4.1 with Gmail SMTP method.

#45 Updated by Jan from Planio www.plan.io almost 4 years ago

  • Related to Defect #15775: Email delivery error: wrong argument (Fixnum)! (Expected kind of OpenSSL::SSL::SSLContext) added

#46 Updated by Miquel Coll over 3 years ago

Mikael Nehlsen wrote:

Being impatient I tried some things and found out that what did work was

gem install mail -v 2.5.3

edit the file Gemfile.lock in the redmine root dir update from mail (2.5.4) to mail (2.5.3) and restart in my case apache.

Thanks! This also worked for me. I'm using redmine 2.4.5 and a Gmail account in configuration.yml.

#47 Updated by Alexander Dunin about 3 years ago

My settings for mandrill

email_delivery:
  delivery_method: :smtp
  smtp_settings:
    address: "smtp.mandrillapp.com" 
    port: 587
    domain: "smtp.mandrillapp.com" 
    authentication: :plain
    user_name: "username@example.com" 
    password: "password" 
    openssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
    enable_starttls_auto: false

#48 Updated by Jin Ma almost 3 years ago

My Redmine version is 2.6.0
When I configure my email, I got an error:
Email delivery error: wrong argument (Fixnum)! (Expected kind of OpenSSL::SSL::SSLContext)

here is my configs

production:
  delivery_method: :smtp
  smtp_settings:
    ssl: true
    enable_starttls_auto: true
    openssl_verify_mode: 'none'
    address: "smtp.exmail.qq.com" 
    port: 465 
    domain: "zuinianqing.com" 
    authentication: :login
    user_name: "redmine@zuinianqing.com" 
    password: "XXXXXXX" 

Could you help me?

#49 Updated by Allen Huang over 2 years ago

I found the solution from http://www.parorrey.com/blog/project-management/redmine-email-configuration-resolve-sending-email-notifications/ works for me.
The key is adding followings to configuration.yml file

      enable_starttls_auto: false
      openssl_verify_mode: none

Also available in: Atom PDF