What's the differences between the Mailer and the Message classes? In the Craft 3 Class Reference (https://docs.craftcms.com/api/v3), there are two classes under craft\mail:


Mailer
Message


I found that I was able to send an email using this:

&lt;?php 

use craft\mail\Message;

$message = new Message();
$message-&gt;setTo('john@doe.com');
$message-&gt;setSubject("Hello world.");
$message-&gt;setHtmlBody("Hello world.");
$message-&gt;send();


But I found in some examples, like this one, that the email could be send using Craft::$app-&gt;mailer-&gt;send($message) instead of $message-&gt;send().

What's the difference between the Mailer and the Message classes? When should I use one instead of the other?
They're both valid options.

$message-&gt;send() is a wrapper for Mailer:

https://github.com/yiisoft/yii2/blob/master/framework/mail/BaseMessage.php#L41-L50

It will take an optional Mailer parameter.  If one is not passed it, it will default to the default Yii/Craft::$app->mailer and ultimately just call send() on it.