#Rails でモデルを作らずに1行ですぐにメール送信する。 ( ActionMailer::Base.mail )


モデルなどを作らず、すぐ送信。

ActionMailer::Base.mail(from: '[email protected]', to: '[email protected]', subject: "Welcome to My Awesome Site", body: 'I am the email body.').deliver
ActionMailer::Base#mail: processed outbound mail in 881.3ms
Sent mail to to@domain.com (190.0ms)
Date: Sun, 13 Oct 2019 09:22:10 +0000
From: from@domain.com
To: to@domain.com
Message-ID: <5da2ecc288c87_342b142f80e5f8474e8@25c1308432ca.mail>
Subject: Welcome to My Awesome Site
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

I am the email body.
=> #<Mail::Message:47365763437540, Multipart: false, Headers: <Date: Sun, 13 Oct 2019 09:22:10 +0000>, <From: [email protected]>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: Welcome to My Awesome Site>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>>

actionmailer - Rails one liner email sending? - Stack Overflow

Original by Github issue