Rails 3-Devise / ActionMailer / RUBY-SMTP导致分段错误 [英] Rails 3 - Devise/ActionMailer/RUBY-SMTP causing a segmentation fault
问题描述
好的-我在这里头顶。我正在使用:
OK - I'm in way over my head here. I'm using:
- ruby-1.9.3-p0
- rails-3.1.3
- mail-2.3.0
- devise-1.5.3
尝试打开Devise的:confirmable
选项,然后在我的应用中启动smtp服务。一旦添加 /config/initializers/setup_mail.rb
,就在数据库中添加Devise的必要列,并添加:confirmable $ c $我的
User
模型的c>属性,出现了细分错误。用户注册后立即发生。 Devise
试图发送确认电子邮件,导致ruby smtp库崩溃,并显示以下内容:
Trying to turn on Devise's :confirmable
option and start up smtp services in my app. As soon as I add /config/initializers/setup_mail.rb
, add Devise's necessary columns in my DB, and the :confirmable
attribute to my User
model, I get a segmentation fault. It occurs right after a user signs up. Devise
is trying to send out the confirmation email, causing the ruby smtp library to crash with the following:
... lib/ruby/1.9.1/net/smtp.rb:583: [BUG] Segmentation fault
log / development.log
中的最后一个条目:
Rendered devise/mailer/confirmation_instructions.html.erb (1.2ms)
我的 /config/initializers/setup_mail.rb
文件:
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "support@mydomain.com",
:password => "???????",
:authentication => "plain",
:enable_starttls_auto => true
}
ActionMailer::Base.default_url_options[:host] = "localhost:3000"
我的 config / environments / development.rb
文件具有以下内容:
My config/environments/development.rb
file has the following:
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
这是ruby / 1.9.1 / net / smtp中的德语代码.rb(第583行位于中间位置附近):
Here is the germane code from ruby/1.9.1/net/smtp.rb (line 583 is near the middle):
def ssl_socket(socket, context)
OpenSSL::SSL::SSLSocket.new socket, context
end
def tlsconnect(s)
verified = false
s = ssl_socket(s, @ssl_context)
logging "TLS connection started"
s.sync_close = true
s.connect # THIS IS LINE 583
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
s.post_connection_check(@address)
end
verified = true
s
ensure
s.close unless verified
end
当smtp尝试通过SSL套接字连接( s.connect
)。在 setup_mail.rb
中,我尝试将:enable_starttls_auto
设置为两个 true
和 false
。将分段设置为 false
时,我没有收到分段错误,但是没有电子邮件发送出去,所以这没用。
It looks like the segmentation fault occurs when smtp is trying to connect via a SSL socket connection ( s.connect
). In setup_mail.rb
I've tried setting :enable_starttls_auto
to both true
and false
. I don't get the segmentation fault when it is set to false
but no email goes out, so that is useless.
通过从Mac运行以下命令,我可以轻松连接到gmail的smtp服务:
I'm easily able to connect to gmail's smtp service by running this command from my Mac:
$ telnet smtp.gmail.com 587
不确定要去哪里
推荐答案
问题出在Rails与OpenSSL交互的方式上。这篇文章总结得很好。 http://www.22ideastreet.com/debug/smtp-rb14- bug-segmentation-fault /
The issue is with the way Rails interacts with OpenSSL. This post sums it up very well. http://www.22ideastreet.com/debug/smtp-rb14-bug-segmentation-fault/
解决方法是将其添加到您的.bashrc / .zshrc / .bash_profile
The fix is to add this to your .bashrc/.zshrc/.bash_profile
export RUBYOPT="-ropenssl"
这篇关于Rails 3-Devise / ActionMailer / RUBY-SMTP导致分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!