What are some best practices for sending system emails using PEAR Mail in PHP?

When sending system emails using PEAR Mail in PHP, it is important to follow best practices to ensure successful delivery and avoid being marked as spam. Some best practices include setting proper headers, using a valid sender email address, and including relevant content in the email body.

<?php
require_once "Mail.php";

$from = "Sender Name <sender@example.com>";
$to = "Recipient Name <recipient@example.com>";
$subject = "Subject of the email";
$body = "This is the content of the email.";

$headers = array(
    'From' => $from,
    'To' => $to,
    'Subject' => $subject
);

$smtp = array(
    'host' => 'smtp.example.com',
    'port' => 25,
    'auth' => true,
    'username' => 'username',
    'password' => 'password'
);

$mail = Mail::factory('smtp', $smtp);

$mail->send($to, $headers, $body);
?>