How to programmatically send email in html format in Drupal 8

  1. First at all, install and activate the 'SMTP Authentication Support' module.
  2. Go to Configuration -> System -> SMTP Authentication Support 
    • Turn on the module as above figure.
    • Input login information inside the group box of 'SMTP AUTHENTICATION'.​​​​​​​​​​​​​​
  3. Check the "Allow to send e-mails formatted as HTML" option on the group box of  "E-MAIL OPTIONS".
    enable html email drupal​​​​​​​
  4. Finally,  install and activate the "Simple Mail" module. Now, you can send email by the following function simply.
    simple_mail_send($from, $to, $subject, $body);