- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我尝试为电子邮件通知配置 redmine
所以我在 configuration.yml
中的配置是:
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: "smtp.gmail.com"
port: '587'
domain: "smtp.gmail.com"
authentication: :plain
user_name: "mymail@gmail.com"
password: "mypass"
根据本教程:
但是当我尝试:发送测试邮件时,我遇到了这个错误:
An error occurred while sending mail (530 5.7.0 Must issue a STARTTLS command first. n7sm25368265eef.5 - gsmtp )
如果我有:
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: "mymail@gmail.com"
password: "mypass"
我有这个错误:
An error occurred while sending mail (SSL_connect returned=1 errno=0 state=unknown state: unknown protocol)
有什么想法吗? Redmine 版本:2.0.1,Ruby:1.9.3
最佳答案
1.将以下代码保存在您的 Rails 应用中的 lib/smtp_tls.rb
中:
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@socket = Net::InternetMessageIO.new(sock)
@socket.read_timeout = 60 #@read_timeout
#@socket.debug_output = STDERR #@debug_output
check_response(critical { recv_response() })
do_helo(helodomain)
if starttls
raise 'openssl library not installed' unless defined?(OpenSSL)
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.sync_close = true
ssl.connect
@socket = Net::InternetMessageIO.new(ssl)
@socket.read_timeout = 60 #@read_timeout
#@socket.debug_output = STDERR #@debug_output
do_helo(helodomain)
end
authenticate user, secret, authtype if user
@started = true
ensure
unless @started
# authentication failed, cancel connection.
@socket.close if not @started and @socket and not @socket.closed?
@socket = nil
end
end
def do_helo(helodomain)
begin
if @esmtp
ehlo helodomain
else
helo helodomain
end
rescue Net::ProtocolError
if @esmtp
@esmtp = false
@error_occured = false
retry
end
raise
end
end
def starttls
getok('STARTTLS') rescue return false
return true
end
def quit
begin
getok('QUIT')
rescue EOFError, OpenSSL::SSL::SSLError
end
end
end
2.将此代码添加到 config/environment.rb
(在其他所有内容之后):
require “smtp_tls”
ActionMailer::Base.smtp_settings = {
:address => “smtp.gmail.com”,
:port => 587,
:authentication => :plain,
:user_name => “someone@openrain.com”,
:password => ’someonesPassword’
}
3.正常使用ActionMailer。
关于ruby-on-rails - 红矿: send mail via gmail error SSL_connect or STARTTLS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21464238/
我想禁用 def/while/class/etc 的 end 自动插入。在 Rubymine 7.0 中。 例如,如果我输入 def 并按 Enter 键,则会在新行下方自动添加 end: # Bef
rubyMine 在运行所有模型测试时出现“检测到 MiniTest 框架”错误。 我可以在常规命令行运行所有模型测试。例如rake 规范:模型 当我使用 rubyMine 时: 我可以运行一个模
在 RubyMine 中进行调试时,如何在断点暂停期间进入 Rails 控制台 session ? 最佳答案 据我所知,这是不可能的。我能弄清楚的最接近的是在调试器中评估上下文感知表达式:http:/
我是一名优秀的程序员,十分优秀!