Sending Emails in PHP with PHPMailer

You don’t need to call clearAllRecipients or clearAllAttachments unless you’re in a loop where you’re reusing the same instance of PHPMailer, such as in the mailing list example provided with PHPMailer.

Sender is used to provide a path back to the origin - it gets converted into the return-path by the receiver. It’s not just used in a sender header within the message, it’s also used as the SMTP envelope sender, and so is commonly used for VERP addressing. If you don’t set it yourself, your mail server will do it for you, but that may mean it’s not set to what you expect.

html to text conversion is really a bit outside PHPMailer’s scope - there used to be a bundled converter, but that had to be removed for license reasons. Now there is only a basic converter, but you can inject your own through the html2text function that is also used internally when you call msgHTML.