为什么延迟作业不能与我的 ActionMailer 生产设置配合使用?
我正在开发一个 Ruby (1.8.6) on Rails (2.3.5) 应用程序,目前我在其中使用 Gmail 来发送电子邮件。我想切换为发送带有延迟作业的消息。
我在开发环境中延迟了发送消息的作业,但当我部署到生产服务器并尝试消息时,消息被拒绝,并且我的elaided_jobs 表中显示错误:530 5.7.0 必须首先发出 STARTTLS 命令。 i25sm12946175anh.17。
我以前见过此错误(当我的配置中没有启用 TLS 时)。但在我开始使用delayed_jobs之前它就可以工作了。这是我的邮件配置:
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'example.com',
:authentication => :plain,
:user_name => '[email protected]',
:password => 'password'
}
非常感谢有关此问题的任何帮助。
更新:该应用程序实际上在 REE ruby 1.8.7 上运行。因此,延迟的作业可能以某种方式使用服务器上安装的常规 ruby 解释器(1.8.6)。但是,如何获得延迟的作业来使用我的 REE 安装?我如何知道哪些东西正在使用哪个版本的 Ruby。
I am working on a Ruby (1.8.6) on Rails (2.3.5) application in which I am currently using Gmail to deliver email messages. I want to switch to sending the messages with Delayed Jobs.
I have delayed jobs sending messages on my development environment but when I deploy to my production server and try the messages get rejected and an error shows up in my delayed_jobs table: 530 5.7.0 Must issue a STARTTLS command first. i25sm12946175anh.17.
I've seen this error before (when I don't have TLS enabled in my config). But it was working before I started using delayed_jobs. Here is my mail config:
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'example.com',
:authentication => :plain,
:user_name => '[email protected]',
:password => 'password'
}
Any help with this issue is greatly appreciated.
Update: The application is actually running on REE ruby 1.8.7. So maybe delayed jobs is somehow using the regular ruby interpreter installed on the server (1.8.6). But, how do I get delayed jobs to use my REE install? And how do I tell what things are using what version of Ruby.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常你会像你写的那样使用
:enable_starttls_auto
,但这仅适用于 ruby >= 1.8.7 和 ruby >= 1.9。因此,您需要使用此处所述的解决方案:定义一个文件
smtp_tls.rb
将其放置在初始化程序文件夹中。Normally you would use
:enable_starttls_auto
as you wrote, but that only works for ruby >= 1.8.7 and ruby >= 1.9.So you need to use the solution as stated here: define a file
smtp_tls.rb
which you place in your initializers folder.script/delayed_job
命令使用系统 Ruby。因此“which ruby
”应该指向 REE 安装。如果没有,您可以使用 Ruby 可执行文件强制执行。假设您的 REE 安装在/opt/ruby-enterprise-1.8.7-2010.01
处。然后:或者如果您使用 rake 命令启动,例如:
那么
which rake
应该指向您的 REE 安装。如果不是,那么您可以通过以下方式使其使用 REE:The
script/delayed_job
command uses the system Ruby. So "which ruby
" should point to the REE installation. If not, you can force it by using the Ruby executable. Lets say, your REE is installed at/opt/ruby-enterprise-1.8.7-2010.01
. Then:Or if you use the rake command to start, like:
Then
which rake
should point to your REE installation. If its not, then you can make it use REE by: