Template files
Mail template files reside in the "templates/" folder of your theme just like any other templates. Since the exact folder doesn't matter, we recommend creating a sub-folder "mail" inside your templates-folder to make things a bit less confusing.
You can then create a file for your mail template. The file names always have the form "mail--[MAILID].html.twig" for HTML mails or "mail--[MAILID].txt.twig" for plain text mails. The "[MAILID]" can be any arbitary machine name under which you'd like to call your mail template later. If you, however, want to have DrupalX send that mail automatically on a form submit, you must use your form's ID as "[MAILID"].
If you have, for example a contact form with form ID/machine name "register", then you'd use the filename "mail--register.html.twig" for your template. Now, let's create a first template to see what it looks like:
{%
set Mail->from="example@drupal.org";
set Mail->to="info@drupalx.org";
set Mail->subject="Registration successful";
%}
<h1>Welcome</h1>
<p>Thank you for registering at DrupalX.</p>
As you can see, the current Mail object can be accessed within that template by using DrupalX's singleton operator.