Edge 支持此功能,但 ActionMailbox::TestHelper 6.0.3.2 尚未实现。
作为一种解决方法,我想出了这个:
subject do
mail = Mail.new do
to 'nicolas@test.lindsaar.net.au'
from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
subject 'First multipart email sent with Mail'
text_part do
body 'Here is the attachment you wanted'
end
html_part do
content_type 'text/html; charset=UTF-8'
body '<h1>Funky Title</h1><p>Here is the attachment you wanted</p>'
end
add_file File.join(File.dirname(__FILE__), '../support/fixtures/image.jpeg')
end
# Tap the route for processing.
create_inbound_email_from_source(mail.to_s, status: :processing).tap(&:route)
end
如果您使用的是边缘或更新版本,这应该可以工作:
receive_inbound_email_from_mail do |mail|
mail.to "David Heinemeier Hansson <david@loudthinking.com>"
mail.from "Bilbo Baggins <bilbo@bagend.com>"
mail.subject "Come down to the Shire!"
mail.text_part do |part|
part.body "Please join us for a party at Bag End"
end
mail.html_part do |part|
part.body "<h1>Please join us for a party at Bag End</h1>"
end
mail.add_file File.join(File.dirname(__FILE__), '../support/fixtures/image.jpeg')
end
注意:您需要更改文件路径以满足您的需要。和receive_
方法相同,create_
但它们处理邮件。