HTTP ERROR 500 just means your PHP code crashed. To see why it crashed, you may want to enable Display Errors. You can learn more about that in this article:
As for the question in the title: using PHPMailer here should work exactly the same as it works anywhere else.