99Problems 99Problems - 3 months ago 9
HTML Question

PHPMAILER - do I need to initialize it every time I send a mail?

I use PHPMailer to send Emails.
Now I need to send multiple different emails at a point of my application.

So first i do the frist email


  • initalize PHPMailer

  • fill FROM/ADRESS/BODY

  • send it



now the second email


  • initalize PHPMailer

  • fill FROM/ADRESS/BODY

  • send it



my question is, do I really have to initialize the PHPMailer for every email? Or is there a other method to reset all previous ADRESS-field i.e. ?

Answer

If you want to use the same PHPMailer object again, you can use the clear-methods of PHPMailer, e.g. the clearAdresses-method or clearAllRecipients-method:

$yourphpmailer->clearAddresses();