[英]How to send a mail via ruby with mail gem?
我尝试使用 ruby 邮件 gem 发送一封简单的邮件:
require 'mail'
options = { :address => "smtp.1und1.de",
:port => 465,
:domain => 'xyz.info',
:user_name => 'abc@xyz.info',
:password => 'yessss',
:authentication => 'login',
:enable_starttls_auto => true }
Mail.defaults do
delivery_method :smtp, options
end
Mail.deliver do
to 'info@xyz.de'
from 'info@xyz.de'
subject 'testing sendmail'
body 'testing sendmail'
end
但我得到的只是以下错误:
*H:\04_PRUPLA\12_RUBY_TOOLS\21_MAILER>ruby MAILER_001.rb
Traceback (most recent call last):
13: from MAILER_001.rb:17:in `<main>'
12: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mail-2.7.1/lib/mail/mail.rb:133:in `deliver'
11: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mail-2.7.1/lib/mail/message.rb:262:in `deliver'
10: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mail-2.7.1/lib/mail/message.rb:2159:in `do_delivery'
9: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
8: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
7: from C:/Ruby27-x64/lib/ruby/2.7.0/net/smtp.rb:518:in `start'
6: from C:/Ruby27-x64/lib/ruby/2.7.0/net/smtp.rb:553:in `do_start'
5: from C:/Ruby27-x64/lib/ruby/2.7.0/net/smtp.rb:954:in `critical'
4: from C:/Ruby27-x64/lib/ruby/2.7.0/net/smtp.rb:553:in `block in do_start'
3: from C:/Ruby27-x64/lib/ruby/2.7.0/net/smtp.rb:944:in `recv_response'
2: from C:/Ruby27-x64/lib/ruby/2.7.0/net/protocol.rb:201:in `readline'
1: from C:/Ruby27-x64/lib/ruby/2.7.0/net/protocol.rb:191:in `readuntil'
C:/Ruby27-x64/lib/ruby/2.7.0/net/protocol.rb:225:in `rbuf_fill': end of file reached (EOFError)*
有什么建议吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.