What are some best practices for using PHPMailer in HTML emails to avoid formatting errors in Outlook?

When using PHPMailer to send HTML emails, it is important to ensure that the HTML code is properly formatted to avoid display issues in Outlook. One common issue is the use of inline styles instead of external CSS, as Outlook may not render inline styles correctly. To avoid formatting errors, it is recommended to use external CSS stylesheets and test the email in Outlook before sending it out.

$mail = new PHPMailer(true);

$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';

$mail->Subject = 'Subject of the email';
$mail->Body = '<html>
<head>
<style>
body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #333333;
}
</style>
</head>
<body>
<p>This is the content of the email.</p>
</body>
</html>';

$mail->send();