How can PHP be used to allow users to send emails from a different domain on a website?

When sending emails from a different domain on a website using PHP, you need to set the "From" header in the email to the desired email address. This can be achieved by using the `additional_headers` parameter in the `mail()` function to specify the "From" header.

$to = "recipient@example.com";
$subject = "Subject of the email";
$message = "This is the message content";
$headers = "From: sender@example.com";

mail($to, $subject, $message, $headers);