method
create_inbound_email_from_mail
rails latest stable - Class:
ActionMailbox::TestHelper
create_inbound_email_from_mail(status: :processing, **mail_options, &block)public
Creates an InboundEmail by specifying through options or a block.
Options
-
:status - The status to set for the created InboundEmail. For possible statuses, see its documentation.
Creating a simple email
When you only need to set basic fields like from, to, subject, and body, you can pass them directly as options.
create_inbound_email_from_mail(from: "[email protected]", subject: "Hello!")
Creating a multi-part email
When you need to create a more intricate email, like a multi-part email that contains both a plaintext version and an HTML version, you can pass a block.
create_inbound_email_from_mail do to "David Heinemeier Hansson <[email protected]>" from "Bilbo Baggins <[email protected]>" subject "Come down to the Shire!" text_part do body "Please join us for a party at Bag End" end html_part do body "<h1>Please join us for a party at Bag End</h1>" end end
As with Mail.new, you can also use a block parameter to define the parts of the message:
create_inbound_email_from_mail do |mail| mail.to "David Heinemeier Hansson <[email protected]>" mail.from "Bilbo Baggins <[email protected]>" 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 end