2
我無法獲得Mail
(或Pony
就此事)連接通過smtp服務器發送電子郵件,憑證,端口號和地址參數我知道是對的。但是,當使用郵件客戶端(雷鳥,墨水等)時,我可以很好地連接。GMX && Ruby Mail SMTP:「達到文件末尾」
這裏是堆棧跟蹤我越來越:
ruby gmx_test.rb
/Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:153:in `read_nonblock': end of file reached (EOFError)
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:153:in `rbuf_fill'
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:134:in `readuntil'
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:144:in `readline'
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:937:in `recv_response'
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:554:in `block in do_start'
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:947:in `critical'
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:554:in `do_start'
from /Users/sy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/smtp.rb:519:in `start'
from /Users/sy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
from /Users/sy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery'
from /Users/sy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/message.rb:234:in `deliver'
from /Users/sy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/mail.rb:140:in `deliver'
from gmx_test.rb:29:in `<main>'
下面是代碼生成:
require 'mail'
gmx_options = { :address => "mail.gmx.com",
:port => 465,
:user_name => '<username_redacted>@gmx.com',
:password => '<password_redacted>',
:authentication => 'plain',
:enable_starttls_auto => true }
Mail.defaults do
delivery_method :smtp, gmx_options
end
Mail.deliver do
to '<redacted>
from '<username_redacted>@gmx.com'
subject 'TEST'
body 'Hi.'
end
這裏的桌面電子郵件客戶端之一的服務器設置的屏幕截圖,並將能夠發送電子郵件:
最終情節扭曲:如果我使用Gmail的smtp,此代碼有效。
感謝您的任何見解,你們可能有!
在'gmx_options'哈希中,您可以嘗試添加':domain =>'gmx.com''嗎? –
是的,這實際上是個好主意。不幸的是,它沒有奏效。 – sybohy
有沒有其他的端口可以試用? –