Unable to send mail with stmp gmail server (in discourse)

I am trying to configure discourse , which is rails3 webapp, but there are some problems with configuring smtp with gmail smtp server.

Yesterday I registered a new gmail account, and I can log in to the browser and the mail client.

Then I configure the discourse in the config/environments/production.rb file:

 config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => "587", :user_name => " smtp4shuzu@gmail.com ", :password => "12345678", :authentication => :plain, :domain => "shuzhu.org", :enable_starttls_auto => true } 

Run sidekiq , which is used to send emails in the background:

 nohup bundle exec sidekiq > log/sidekiq.log 2>&1 & 

Then run the discourse in production mode:

 rails server -e production -d 

But that will not work. I see some errors in sidekiq.log :

2013-03-01T03: 06: 02Z 30687 TID-qib28 WARN: {"retry" => true, "queue" => "default", "class" => "Jobs :: UserEmail", "args" => [ {"type" => "signup", "user_id" => 42, "email_token" => "b40a21ece2b14586e346abfd96685975", "current_site_id" => "default"}], "jid" => "558bb6bd5aa36cfc8d3d1e91", " > "Connection reject - connect (2)", "error_class" => "Errno :: ECONNREFUSED", "failed_at" => 2013-03-01 03:06:02 UTC, "retry_count" => 0} 2013-03 -01T03: 06: 02Z 30687 TID-qib28 WARN: connection refused - connect (2) 2013-03-01T03: 06: 02Z 30687 TID-qib28 WARN: /home/discourse/.rvm/rubies/ruby-1.9.3- p385 / lib / ruby ​​/ 1.9.1 / net / smtp.rb: 540: in initialize' /home/discourse/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/smtp.rb:540:in open "/home/discourse/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/smtp.rbβ–Ί40:in` tcp_socket '

I tried all kinds of smtp settings, but none of them work.


UPDATE

In response to @Basil, I just tried:

 config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :user_name => "smtp4shuzu", :password => "12345678", :authentication => "plain", :enable_starttls_auto => true } 

But he has the same error. The shuzu.org domain is the domain of my site, I thought I should transfer it to smtp. Now I deleted it, but still did not work.

+4
source share
4 answers

Finally, I found a (stupid) reason.

I have to start sidekiq in working mode:

 nohup bundle exec sidekiq -e production > log/sidekiq.log 2>&1 & 
+5
source

Try removing quotes around the port.

  :port => 587, 

Also, I don’t understand why your email address is @gmail, but your domain is @shuhzu ... The smtp options should show the domain for your email account. If you have custom gmail, ie me@custom.com , then the domain will be custom.com. The following is an example of what smtp settings for your domain should be if you have your own email address:

 { :address => "smtp.gmail.com", :port => 587 , :domain => "custom.com", :user_name => " some_email@custom.com ", :password => "some_password", :authentication => "plain", :enable_starttls_auto => true } 
+2
source

In my installation, which is one of those prebuilt images (Bitnami), I just had to run this:

 /opt/discourse-0.9.5-0/ctlscript.sh start discourse_sidekiq 

Does anyone know how I can automate this to happen at startup?

0
source

I just set up a new instance of the discourse in the docker container on my own physical ubuntu server on the site server and edited app.yml to contain:

 DISCOURSE_SMTP_ADDRESS: 'smtp.gmail.com' DISCOURSE_SMTP_AUTHENTICATION: 'plain' DISCOURSE_SMTP_PORT: 587 DISCOURSE_SMTP_USER_NAME: ' my.name@gmail.com ' DISCOURSE_SMTP_PASSWORD: 'myPa$$word' DISCOURSE_SMTP_ENABLE_START_TLS: true 

and it worked. Half the battle knew where to put the single inverted commas (') and where not to do it.

Another way was also available to me - my ISP provides smtp relays for static IP clients, so I used this in app.yam:

 DISCOURSE_SMTP_ADDRESS: mail.myisp.tld DISCOURSE_SMTP_AUTHENTICATION: none DISCOURSE_SMTP_PORT: 25 

and it works for me.

0
source

All Articles