我正在尝试使用'mail'gem发送电子邮件(使用OCRA打包),但我收到一条错误消息:
=== Loading script to check dependencies
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mail-2.6.6/lib/mail/check_delivery_params.rb:
13:in `check_from': SMTP From address may not be blank: nil (ArgumentError)
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mail-2.6.6/lib/mail/check_delive
ry_params.rb:6:in `check'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mail-2.6.6/lib/mail/network/deli
very_methods/smtp.rb:97:in `deliver!'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mail-2.6.6/lib/mail/message.rb:2
149:in `do_delivery'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mail-2.6.6/lib/mail/message.rb:2
39:in `deliver'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mail-2.6.6/lib/mail/mail.rb:141:
in `deliver'
from c:/BacklogAlert.rb:140:in `send_email'
from c:/BacklogAlert.rb:163:in `<top (required)>'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/ocra-1.3.10/bin/ocra:1211:in `lo
ad'
from C:/Ruby23/lib/ruby/gems/2.3.0/gems/ocra-1.3.10/bin/ocra:1211:in `<t
op (required)>'
from C:/Ruby23/bin/ocra:22:in `load'
from C:/Ruby23/bin/ocra:22:in `<main>'
问题是我们正在使用内部smtp邮件中继,它只允许设备发送给内部收件人,因此不需要“发件人”地址。
这是我的代码:
Mail.defaults do
delivery_method :smtp, mail_options
end
Mail.deliver do
to email_recipient
from email_sender
subject 'Test email ' + today_date
body 'Attached is a file'
add_file test_file
end
如何在不指定“发件人”地址的情况下收到要发送的电子邮件?