问题描述
我正在尝试设置 discourse ,这是一个rails3 Web应用程序,但是在使用gmail配置smtp时遇到了一些问题smtp服务器.
I'm trying to setup discourse, which is a rails3 webapp, but have some problems configuring smtp with gmail smtp server.
我昨天注册了一个新的Gmail帐户,并且可以登录浏览器和电子邮件客户端软件.
I have registered a new gmail account yesterday, and I can logged in browser and email-client software.
然后我在文件config/environments/production.rb
中配置语篇:
Then I configure discourse, in the file config/environments/production.rb
:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:user_name => "[email protected]",
:password => "12345678",
:authentication => :plain,
:domain => "shuzhu.org",
:enable_starttls_auto => true
}
启动用于在后台发送邮件的sidekiq
:
Start the sidekiq
which is used to sending the mails in the background:
nohup bundle exec sidekiq > log/sidekiq.log 2>&1 &
然后以生产模式开始演讲:
Then start discourse in production mode:
rails server -e production -d
但是它不起作用.我可以在sidekiq.log
中看到一些错误:
But it doesn't work. I can see some errors in sidekiq.log
:
我尝试了各种smtp设置,但没有一个起作用.
I have tried all kinds of smtp settings, but none of them works.
更新:
每个@Basil的答案,我都尝试过:
Per @Basil's answer, 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
}
但是它有相同的错误.域shuzu.org
是我的站点的域,我当时想将其传递给smtp.现在,我将其删除,但仍无法正常工作.
But it has the same error. The domain shuzu.org
is the domain of my site, I was thinking I should passing it to smtp. Now I removed it, but still not working.
推荐答案
最后,我发现了(愚蠢的)原因.
At last, I found the (stupid) reason.
我应该在生产模式下启动sidekiq
:
I should start sidekiq
in production mode:
nohup bundle exec sidekiq -e production > log/sidekiq.log 2>&1 &
这篇关于无法通过Gmail SMTP服务器发送邮件(在讨论中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!