How to send email from Craft 3 custom plugin? I have created custom plugin in Craft 3 and want send email to receiver or site email when user submits a form.
Edit: After the migration to Craft 3.1.x you should rather use this Code
/**
 * @param string                            $html
 * @param string                            $subject
 * @param array|string|\craft\elements\User $mail
 *
 * @return bool
 */
public function sendMail(string $html, string $subject, $mail): bool
{
    return Craft::$app
        -&gt;getMailer()
        -&gt;compose()
        -&gt;setTo($mail)
        -&gt;setSubject($subject)
        -&gt;setHtmlBody($html)
        -&gt;send();
}

Edit: this is my old answer, valid for Craft 3.0.x
This is my code to send emails in Craft 3. Let me know if you have any questions.
use craft\mail\Message;

/**
 * @param $html
 * @param $subject
 * @param null $mail
 * @param array $attachments
 * @return bool
 */
private function sendMail($html, $subject, $mail = null, array $attachments = array()): bool
{
    $settings = Craft::$app-&gt;systemSettings-&gt;getSettings('email');
    $message = new Message();

    $message-&gt;setFrom([$settings['fromEmail'] =&gt; $settings['fromName']]);
    $message-&gt;setTo($mail);
    $message-&gt;setSubject($subject);
    $message-&gt;setHtmlBody($html);
    if (!empty($attachments) &amp;&amp; \is_array($attachments)) {

        foreach ($attachments as $fileId) {
            if ($file = Craft::$app-&gt;assets-&gt;getAssetById((int)$fileId)) {
                $message-&gt;attach($this-&gt;getFolderPath() . '/' . $file-&gt;filename, array(
                    'fileName' =&gt; $file-&gt;title . '.' . $file-&gt;getExtension()
                ));
            }
        }
    }

    return Craft::$app-&gt;mailer-&gt;send($message);
}