why does phpmailer class echo texts?

By default it shouldn't generate any output. Make sure it is not wrapped in a print/echo statement/function.

A workaround could be using ob_start() at the beginning and ob_get_clean() at the end of your mailer script, so that it prevents any output from leaving the buffer.


PHPMailer has a "debug" flag that you can turn off.

Depending on which version you are using, it could be named Debug or SMTPDebug. You'll know it when you see it. If necessary, look into the class file to find out the name.

Set that to false and all is well.