Project

General

Profile

Error while sending email through Gmail.

Added by David Díaz over 12 years ago

I get the error: "Ha ocurrido un error mientras enviando el correo (SSL_connect returned=1 errno=0 state=unknown state: unknown protocol)"

System configuration:
- Ubuntu 64
- Apache 2.2
- mod_passenger

Environment configuration:
Environment:
- Redmine version 2.0.0.stable.9699
- Ruby version 1.9.3 (x86_64-linux)
- Rails version 3.2.3
- Environment production
- Database adapter PostgreSQL
Redmine plugins:
no plugin installed

I'm using Redmine 2.0 stable after upgrading from 1.3 (where this configuration works) with the following gemset:

actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.3)
arel (3.0.2)
builder (3.0.0)
bundler (1.1.3)
coderay (1.0.6)
daemon_controller (1.0.0)
erubis (2.7.0)
fastthread (1.0.7)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
json (1.7.3)
mail (2.4.4)
mime-types (1.18)
multi_json (1.3.5)
net-ldap (0.3.1)
passenger (3.0.12)
pg (0.13.2)
polyglot (0.3.3)
prototype-rails (3.2.1)
rack (1.4.1)
rack-cache (1.2)
rack-openid (1.3.1)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.3)
railties (3.2.3)
rake (0.9.2.2)
rdoc (3.12)
rmagick (2.13.1)
ruby-openid (2.1.8)
rubygems-bundler (1.0.0)
rvm (1.11.3.3)
sprockets (2.1.3)
sqlite3 (1.3.6)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)

My email configuration is:

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      tls: true
      enable_starttls_auto: true
      address: "smtp.gmail.com" 
      port: '587'
      domain: "smtp.gmail.com" 
      authentication: :plain
      user_name: "<user@gmail.com>" 
      password: "<password>" 

Thanks


Replies (35)

RE: Error while sending email through Gmail. - Added by Aleksander Demidov over 12 years ago

Yes. I connect in this topic. Redmine 2.0 + Rails 3 = not work sending email via gmail.
action_mailer_optional_tls plugin not work.
Unable to setting SSL an this doc: http://edgeguides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration-for-gmail

Any ideas?

SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol

RE: Error while sending email through Gmail. - Added by David Díaz over 12 years ago

Hi! I found that it is a configuration problem.

First, use the configuration.yml of the redmine2.0 instalation. Don't copy/paste from another version. Then, check all the document to comment all the email configuration blocks. Then use the following email configuration block with exactly the same quotes (only on user_name):

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: smtp.gmail.com
      port: 587
      domain: smtp.gmail.com
      authentication: :plain
      user_name: "user@gmail.com" 
      password: password

RE: Error while sending email through Gmail. - Added by Aleksander Demidov over 12 years ago

David Díaz wrote:

Hi! I found that it is a configuration problem.

First, use the configuration.yml of the redmine2.0 instalation. Don't copy/paste from another version. Then, check all the document to comment all the email configuration blocks. Then use the following email configuration block with exactly the same quotes (only on user_name):

[...]

ohh.. no. It is not work. Without option "tls: true" - I fetched error "530 5.7.0 Must issue a STARTTLS command first". It`s one.
It`s two: Quotes allowed for password and user_name fields - this doc http://www.redmine.org/projects/redmine/wiki/EmailConfiguration#Asynchronous-delivery_methods
OR
in source configuration.yml.example https://github.com/redmine/redmine/blob/master/config/configuration.yml.example
@# ==== SMTP server at using TLS (GMail) #
  1. This might require some additional configuration. See the guides at:
  2. http://www.redmine.org/projects/redmine/wiki/EmailConfiguration #
  3. production:
  4. email_delivery:
  5. delivery_method: :smtp
  6. smtp_settings:
  7. tls: true
  8. enable_starttls_auto: true
  9. address: "smtp.gmail.com"
  10. port: 587
  11. domain: "smtp.gmail.com" # 'your.domain.com' for GoogleApps
  12. authentication: :plain
  13. user_name: ""
  14. password: "your_password"@

After execute test email notification - fetched error "SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol".

David, maybe you install in your machine special tls plugin. How did you that?

RE: Error while sending email through Gmail. - Added by unisol solo over 12 years ago

"SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol".

help!

RE: Error while sending email through Gmail. - Added by unisol solo over 12 years ago

delivery_method: :smtp
smtp_settings:
address: smtp.gmail.com
port: 587
domain: substancelab.com
authentication: login
user_name: ""
password: passw0rd
enable_starttls_auto: true

WORK!!!

delete - tls: true

RE: Error while sending email through Gmail. - Added by David Díaz over 12 years ago

Hi, Aleksander Demidov.

Remove tls: true. You only need enable_starttls_auto: true to enable tls. And then remove quotes (", ") on address, domain and password. The gems that i've installed are posted above and i don't have any special tls gem.

Hope this help you.

RE: Error while sending email through Gmail. - Added by Aleksander Demidov over 12 years ago

Maybe, I use old version gem`s. But gemfile in redmine-2.0 write new version of my gems.
Gem list:

abstract (1.0.0)                                                                                                                     
action_mailer_tls (1.1.3)                                                                                                            
actionmailer (3.2.3, 3.1.0, 3.0.0, 2.3.14, 2.3.11, 2.3.5)                                                                            
actionpack (3.2.3, 3.1.0, 3.0.0, 2.3.14, 2.3.11, 2.3.5)                                                                              
activemodel (3.2.3, 3.1.0, 3.0.0)
activerecord (3.2.3, 3.1.0, 3.0.0, 2.3.14, 2.3.11, 2.3.5)
activeresource (3.2.3, 3.1.0, 3.0.0, 2.3.14, 2.3.11, 2.3.5)
activesupport (3.2.3, 3.1.0, 3.0.0, 2.3.14, 2.3.11, 2.3.5)
ambethia-smtp-tls (1.1.2)
arel (3.0.2, 2.2.1, 1.0.1)
bcrypt-ruby (3.0.1)
builder (3.0.0, 2.1.2)
bundler (1.1.3, 1.0.18)
capistrano (2.12.0)
cgi_multipart_eof_fix (2.5.0)
coderay (1.0.6)
daemon_controller (0.2.6)
daemons (1.1.8, 1.0.10)
dispatcher (0.0.1)
erubis (2.7.0, 2.6.6)
eventmachine (0.12.10)
fastercsv (1.5.5)
fastthread (1.0.7)
gem_plugin (0.2.3)
highline (1.6.12)
hike (1.2.1)
i18n (0.6.0, 0.4.2)
journey (1.0.3)
jruby-pageant (1.0.2)
json (1.7.3)
mail (2.4.4, 2.3.0, 2.2.19)
mime-types (1.18, 1.16)
mongrel (1.2.0.pre2, 1.1.5)
mongrel_cluster (1.0.5)
multi_json (1.3.5, 1.0.3)
mysql (2.8.1)
net-ldap (0.3.1)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.4.0)
net-ssh-gateway (1.1.0)
passenger (3.0.9)
pg (0.13.2)
polyglot (0.3.3, 0.3.2)
prototype-rails (3.2.1)
rack (1.4.1, 1.1.0)
rack-cache (1.2, 1.0.3)
rack-mount (0.8.3, 0.6.14)
rack-openid (1.3.1)
rack-ssl (1.3.2)
rack-test (0.6.1, 0.5.7)
rails (3.2.3, 3.1.0, 3.0.0, 2.3.14, 2.3.11)
railties (3.2.3, 3.1.0, 3.0.0)
rake (0.9.2.2, 0.9.2)
rdoc (3.12, 3.9.4, 2.4.2)
rmagick (2.13.1)
ruby-openid (2.1.8)
rubygems-update (1.8.24)
rubytree (0.8.2)
sprockets (2.1.3, 2.0.0)
sqlite3 (1.3.6)
thin (1.3.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33, 0.3.29)

My gemfile.lock (in redmine-2.0 directory):

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (3.2.3)
      actionpack (= 3.2.3)
      mail (~> 2.4.4)
    actionpack (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.1)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.2)
    activemodel (3.2.3)
      activesupport (= 3.2.3)
      builder (~> 3.0.0)
    activerecord (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
    activesupport (3.2.3)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    arel (3.0.2)
    builder (3.0.0)
    cgi_multipart_eof_fix (2.5.0)
    coderay (1.0.6)
    daemons (1.1.8)
    dispatcher (0.0.1)
    erubis (2.7.0)
    fastercsv (1.5.5)
    fastthread (1.0.7)
    gem_plugin (0.2.3)
    hike (1.2.1)
    i18n (0.6.0)
    journey (1.0.3)
    json (1.7.3)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    metaclass (0.0.1)
    mime-types (1.18)
    mocha (0.11.4)
      metaclass (~> 0.0.1)
    mongrel (1.2.0.pre2)
      daemons (~> 1.0.10)
      gem_plugin (~> 0.2.3)
    multi_json (1.3.5)
    mysql (2.8.1)
    mysql2 (0.3.11)
    net-ldap (0.3.1)
    pg (0.13.2)
    polyglot (0.3.3)
    prototype-rails (3.2.1)
      rails (~> 3.2)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-openid (1.3.1)
      rack (>= 1.1.0)
      ruby-openid (>= 2.1.8)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.2.3)
      actionmailer (= 3.2.3)
      actionpack (= 3.2.3)
      activerecord (= 3.2.3)
      activeresource (= 3.2.3)
      activesupport (= 3.2.3)
      bundler (~> 1.0)
      railties (= 3.2.3)
    railties (3.2.3)
      actionpack (= 3.2.3)
      activesupport (= 3.2.3)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    rmagick (2.13.1)
    ruby-openid (2.1.8)
    shoulda (2.11.3)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.6)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.33)

PLATFORMS
  ruby

DEPENDENCIES
  activerecord-jdbcmysql-adapter
  activerecord-jdbcpostgresql-adapter
  activerecord-jdbcsqlite3-adapter
  builder
  cgi_multipart_eof_fix
  coderay (~> 1.0.6)
  dispatcher
  fastercsv (~> 1.5.0)
  fastthread
  i18n (~> 0.6.0)
  jruby-openssl
  mocha
  mongrel (= 1.2.0.pre2)
  mysql
  mysql2 (~> 0.3.11)
  net-ldap (~> 0.3.1)
  pg (>= 0.11.0)
  prototype-rails (= 3.2.1)
  rack-openid
  rails (= 3.2.3)
  rdoc (>= 2.4.2)
  rmagick (>= 2.0.0)
  ruby-openid (~> 2.1.4)
  shoulda (~> 2.11)
  sqlite3

My settings in configuration.yml:

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

After execute test notification mail, fetch error: "530 5.7.0 Must issue a STARTTLS command first. n19sm30590948bkv.14".
Why in you it work, but from my not work?

RE: Error while sending email through Gmail. - Added by Sungjin Kim over 12 years ago

I have solved in Redmine 2.0

1. Don't install "action_mailer_optional_tls" plugin.
2. Copy gmail setting example in "configuration.example" into "configuration.xml"
IMPORTANT : Keep space and tab .

# production:
#   email_delivery:
#     delivery_method: :smtp
#     smtp_settings:
#       tls: true
#       enable_starttls_auto: true
#       address: "smtp.gmail.com" 
#       port: 587
#       domain: "smtp.gmail.com" # 'your.domain.com' for GoogleApps
#       authentication: :plain
#       user_name: "your_email@gmail.com" 
#       password: "your_password" 

3. Remove "#" and # 'your.domain.com' for GoogleApps and "tls:true" and quotes in address and domain and password. Only remain quotes in user_name.
IMPORTANT : Keep space and tab .

production:
   email_delivery:
     delivery_method: :smtp
     smtp_settings:
       enable_starttls_auto: true
       address: "smtp.gmail.com" 
       port: 587
       domain: "smtp.gmail.com" 
       authentication: :plain
       user_name: "your_email@gmail.com" 
       password: "your_password" 

4. Set your Gmail setting
IMPORTANT : Keep space and tab .

production:
   email_delivery:
     delivery_method: :smtp
     smtp_settings:
       enable_starttls_auto: true
       address: smtp.gmail.com
       port: 587
       domain: smtp.gmail.com
       authentication: :plain
       user_name: "kskyj_test@gmail.com" 
       password: 123455

5. Have fun :0

RE: Error while sending email through Gmail. - Added by Plam Sim about 11 years ago

It works perfect for Redmine 2.4.1 and Gmail SMTP method. I used the syntax described by Sungjin Kim. Thank you very much.

RE: Error while sending email through Gmail. - Added by Thiago Oliveira about 8 years ago

I know that is a old problem but in redmine 3.0.3 i got whe following error:

(Permission denied - connect(2) for "smtp.bsservices.com.br" port 587)

Im using:

Environment:
Redmine version 3.0.3.stable
Ruby version 2.2.2-p95 (2015-04-13) [x86_64-linux]
Rails version 4.2.1
Environment production
Database adapter Mysql2
SCM:
Filesystem
Redmine plugins:
no plugin installed

configuration.yml:

default:
# Outgoing emails configuration (see examples above)
email_delivery:
delivery_method: :smtp
smtp_settings:
    address: "smtp.bsservices.com.br" 
    port: 587
    domain: "smtp.bsservices.com.br" 
    authentication: :login
    user_name: '<user>@bsservices.com.br'
    password: '<password>'
    openssl_verify_mode: 'none'

RE: Error while sending email through Gmail. - Added by Plam Sim about 8 years ago

Hello,

please try with these settings and be very careful to copy paste it exactly like the example below - be careful for "" or non ""

production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: "smtp.bsservices.com.br" 
      port: 587
      domain: smtp.bsservices.com.br
      authentication: :plain
      user_name: "your-user@your-domain.com" 
      password: ***********

Thiago Oliveira wrote:

I know that is a old problem but in redmine 3.0.3 i got whe following error:

(Permission denied - connect(2) for "smtp.bsservices.com.br" port 587)

RE: Error while sending email through Gmail. - Added by Thiago Oliveira about 8 years ago

Plam Sim. Thanks for the tips.
I did exactly what you asked for and the error persist. Maybe the bug is in some ruby configuration or permission to SELinux. I'm using CentOS 7.

RE: Error while sending email through Gmail. - Added by Plam Sim about 8 years ago

I guess you see this "permission denied" message with trying to send a test email under Administration -> Settings -> Email notifications and then close to the bottom right "Send a test email"? Or you see it from another place?

Thiago Oliveira wrote:

I did exactly what you asked for and the error persist. Maybe the bug is in some ruby configuration or permission to SELinux. I'm using CentOS 7.

RE: Error while sending email through Gmail. - Added by Thiago Oliveira about 8 years ago

Actually yes. But I also see this error in the log when a task is created and the notification email is not sent.

RE: Error while sending email through Gmail. - Added by Plam Sim about 8 years ago

My suggestion is to create a new Gmail account, activate POP / SMTP for this Gmail and try with my suggestion for the configuration.yml syntax. In that way you can be sure that the issue is not with the syntax.

Thiago Oliveira wrote:

Actually yes. But I also see this error in the log when a task is created and the notification email is not sent.

RE: Error while sending email through Gmail. - Added by Thiago Oliveira about 8 years ago

Pam. I tried using gmail and the error is the same. I made a java class to send email and the email is sent normally. Do you know if there is any specific ruby lib or redmine to send email?

RE: Error while sending email through Gmail. - Added by Plam Sim about 8 years ago

Hi, yest they are. I use also Centos 7.x . But my Ruby is 3.0. I can send emails with no problem.
My gems form mail are versions:

# gem list | grep mail
actionmailer (5.0.0.1, 4.2.7.1)
mail (2.6.4)

Thiago Oliveira wrote:

Pam. I tried using gmail and the error is the same. I made a java class to send email and the email is sent normally. Do you know if there is any specific ruby lib or redmine to send email?

RE: Error while sending email through Gmail. - Added by Thiago Oliveira about 8 years ago

This is what I have:

# gem list | grep mail
actionmailer (4.2.7.1, 4.2.1, 3.2.6)
mail (2.6.4, 2.5.3, 2.4.4)

Maybe if update the ruby and the gem. What you think?

RE: Error while sending email through Gmail. - Added by Thiago Oliveira almost 8 years ago

Look into apache logs i found this:
App 5821 stderr: /bin/bash: /home/www-data/.bash_profile: Permission denied
App 5821 stdout:
App 5821 stderr: /usr/local/lib/ruby/gems/2.2.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: duplicated key at line 466 ignored: "inodot"
App 5821 stderr: Rails Error: Unable to access log file. Please ensure that /var/www/redmine/log/production.log exists and is writable (ie, make it writable for user and group: chmod 0664 /var/www/redmine/log/production.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.

Any help?

RE: Error while sending email through Gmail. - Added by Thiago Oliveira almost 8 years ago

In upload files there is an error for permission denied as well. Maybe they are connected.
I already gave all permission to the folder (777):

App 6529 stderr: Saving attachment '/var/www/redmine/files/2016/12/161223114939_app_creator.PNG' (79469 bytes)
App 6529 stderr: Completed 500 Internal Server Error in 18ms (ActiveRecord: 2.5ms)
App 6529 stderr:
App 6529 stderr: Errno::EACCES (Permission denied
rb_sysopen - /var/www/redmine/files/2016/12/161223114939_app_creator.PNG):
App 6529 stderr: app/models/attachment.rb:109:in `initialize'
App 6529 stderr: app/models/attachment.rb:109:in `open'
App 6529 stderr: app/models/attachment.rb:109:in `files_to_final_location'
App 6529 stderr: app/controllers/attachments_controller.rb:90:in `upload'
@

RE: Error while sending email through Gmail. - Added by Plam Sim almost 8 years ago

I think your redmine installation has to be checked. You should use separate user to own the Redmine folder. You should invoke bundler commands from this user.

Let's say you create new user and group for Redmine

### Create Redmine user and group
redus:redus

### Redmine folder has to be owned by these user and group
sudo chown -R redus:redus /usr/local/share/redmine

### Give permissions in visudo
redus ALL=(ALL) NOPASSWD: /usr/local/share/redmine/bin/rake
redus ALL=(ALL) NOPASSWD: /usr/local/share/redmine/bin/Rakefile

### Repeat bundler install through the new user redus
su - redus
cd /usr/local/share/redmine/
bundle install --without development test postgresql sqlite
bundle exec rake generate_secret_token 
bundle exec rake db:migrate RAILS_ENV=production

### Restart httpd or nginx service
service httpd restart
(or service nginx restart)

This should solve your permissions issues.

RE: Error while sending email through Gmail. - Added by Thiago Oliveira almost 8 years ago

Pam. Thanks for the tips.
I made it, but not working and executing this steps I got it:

bundle exec rake generate_secret_token
/usr/local/lib/ruby/gems/2.2.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: duplicated key at line 466 ignored: "inodot"

bundle exec rake db:migrate RAILS_ENV=production
/usr/local/lib/ruby/gems/2.2.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: duplicated key at line 466 ignored: "inodot"

I dont know what I missing. Maybe its a silly step.

RE: Error while sending email through Gmail. - Added by Plam Sim almost 8 years ago

You mentioned above that you use Redmine 3.0.3. I am not sure if Ruby 2.2 supports Redmine 3.0.x. Redmine 3.0.x is not mentioned here:
http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Requirements

My suggestion is to update Redmine to latest 3.3.1. You can do it and then repeat the commands I suggested above. Redmine 3.3.1 should work with Ruby 2.2.

RE: Error while sending email through Gmail. - Added by Plam Sim almost 8 years ago

You may try with this:
http://stackoverflow.com/questions/27669855/warnings-after-upgrading-to-ruby-2-2-0

Update htmentities or open the file and remove the duplicate key

vi /usr/local/lib/ruby/gems/2.2.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.r
:465 (go to line 465)

Thiago Oliveira wrote:

bundle exec rake generate_secret_token
/usr/local/lib/ruby/gems/2.2.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: duplicated key at line 466 ignored: "inodot"

RE: Error while sending email through Gmail. - Added by Thiago Oliveira almost 8 years ago

Pam... I will install the 3.3 version. But i cant do it right now.
I will do it later and I post the results here.
Thanks again for patience and the tips.

(1-25/35)