How can one ensure proper formatting in text emails without resorting to sending HTML emails in PHP?

To ensure proper formatting in text emails without using HTML in PHP, you can use PHP's wordwrap function to limit the number of characters per line and the PHP nl2br function to convert newlines to <br> tags for line breaks.

// Set the maximum number of characters per line
$lineLength = 70;

// Wrap the text to limit characters per line
$message = wordwrap($message, $lineLength, &quot;\n&quot;, true);

// Convert newlines to &lt;br&gt; tags for line breaks
$message = nl2br($message);

// Send the email with properly formatted text
mail($to, $subject, $message);