Error while sending email through Gmail.

Added by David Díaz over 5 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 Thiago Oliveira 12 months ago

Diging in apache logs i found this:

App 15357 stderr: /bin/bash: /home/www-data/.bash_profile: Permission denied
App 15357 stdout:
App 15357 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 15357 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.

RE: Error while sending email through Gmail. - Added by Thiago Oliveira 12 months ago

Diging in apache logs i found this:

[Wed Dec 28 10:50:04.586007 2016] [mpm_prefork:notice] [pid 15289] AH00163: Apache/2.4.6 (CentOS) Phusion_Passenger/5.1.0 configured -- resuming normal operations
[Wed Dec 28 10:50:04.586059 2016] [core:notice] [pid 15289] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[ 2016-12-28 10:50:05.9681 15322/7f5d14859700 age/Cor/SecurityUpdateChecker.h:348 ]: Security update check: no update found (next check in 24 hours)
[ 2016-12-28 10:50:06.0520 15293/7f23e7f32700 age/Cor/SecurityUpdateChecker.h:348 ]: Security update check: no update found (next check in 24 hours)
[ 2016-12-28 10:50:06.0843 15293/7f23e804a880 age/Cor/CoreMain.cpp:1052 ]: Passenger core shutdown finished
App 15357 stderr: /bin/bash: /home/www-data/.bash_profile: Permission denied
App 15357 stdout:
App 15357 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 15357 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.

RE: Error while sending email through Gmail. - Added by Plam Sim 12 months ago

I think we go too much off the topic of this forum theme. From your post I see that your production log location is set to /var/www/redmine/log/production.log

The correct path should be:
/usr/local/share/redmine/log/production.log

I am not sure who did your Redmine installation and which guide was used, but I guess your installation could has something wrong.

I suggest you to install a clean Redmine 3.3.1 from scratch and transfer your existing data to it. If you need help you can contact me on my skype pcprofix.

Thiago Oliveira wrote:

App 15357 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.
@

RE: Error while sending email through Gmail. - Added by Thiago Oliveira 12 months ago

OK Pam!

I will do it soon as possible and post the results. Thanks again!

RE: Error while sending email through Gmail. - Added by Thiago Oliveira 12 months ago

Pam...
Do you recomend any tutorial to install with apache on centos 7?

RE: Error while sending email through Gmail. - Added by Plam Sim 12 months ago

I haven't followed these tutorials, but they should work. You have to adapt them for latest Redmine version and Centos 7. My setup is different. I use Nginx and Unicorn. I don't use Apache2 and passenger.

http://www.redmine.org/projects/redmine/wiki/How_to_Install_Redmine_on_CentOS_(Detailed)
https://www.server-world.info/en/note?os=CentOS_7&p=redmine

According these tutorials I see that they put Redmine in /var/www/redmine . In that way is normal your production.log to be there. In that case you have to set the ownership for the user for redmine to own this directory.

chown -r redus:redus /var/www/redmine

Thiago Oliveira wrote:

Pam...
Do you recomend any tutorial to install with apache on centos 7?

RE: Error while sending email through Gmail. - Added by Thiago Oliveira 12 months ago

That last tutorial works with some adjustments.

These settings are basically SELinux permissions and settings. For the file upload permissions I used these links:

[[https://www.phusionpassenger.com/library/admin/apache/troubleshooting/ruby/#apache-cannot-access-my-app-s-files-because-of-selinux-errors]]
[[http://linuxism.tistory.com/2016]]
[[http://stackoverflow.com/questions/31949350/cant-upload-files-in-redmine-using-centos-7/41361325#41361325]]

The permissions are correct and follow the tutorials. File uploads and downloads are working normally. But, the email has the same error (another java process normally sends using the same smtp and port).

I will continue to investigate and post when I find a solution.
Thank you Plam.

RE: Error while sending email through Gmail. - Added by Thiago Oliveira 12 months ago

Plammm!!!!

Oh My GOD! Finally i got it!

Analyzing this tutorial ([[http://www.redmine.org/projects/redmine/wiki/FedoraInstallation#Email-Configuration]]) I verified that in the session of "E-mail Configuration" the following explanation exists:

By default with SELinux enabled, the web server cannot open external connections. This is necessary for sending email notifications, even when port 25 is being opened on the localhost. This can be done with the following command:

Then executing this:

$ sudo setsebool httpd_can_network_connect 1

Now the redmine is sending e-mail notifications!

Plam I have to thank you for all the patience and help on this topic.

RE: Error while sending email through Gmail. - Added by Plam Sim 12 months ago

You can try with disabling requiretty in visudo if you still haven't tried it.

RE: Error while sending email through Gmail. - Added by Plam Sim 12 months ago

Very well! I am glad that you found the right solution.

Thiago Oliveira wrote:

By default with SELinux enabled, the web server cannot open external connections. This is necessary for sending email notifications, even when port 25 is being opened on the localhost. This can be done with the following command:

Then executing this:

$ sudo setsebool httpd_can_network_connect 1

Now the redmine is sending e-mail notifications!

1 2 (26-35/35)