Title: Problems when using PHPmailer
Last modified: September 9, 2020

---

# Problems when using PHPmailer

 *  Resolved [brainzilla](https://wordpress.org/support/users/brainzilla/)
 * (@brainzilla)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/problems-when-using-phpmailer/)
 * Hey. Great plugin, but I came across a little problem today.
 * I have my own plugin that uses PHPmailer and naturally declares that class.
    
   That causes Cerber to throw: `PHP Fatal error: Cannot declare class PHPMailer\
   PHPMailer\PHPMailer, because the name is already in use in /<path-to-file>/PHPMailer.
   php on line xx` and even worse not do what it says / should do.
 * Since my plugin is loaded before Cerber (name starts with an A), there is not
   really anything I can do on my side, right? Not sure if loading it with another
   classname would work?
 * So maybe Cerber could check for the existance of the class or try{} – or offer
   an option to use the instance that is already declared?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [gioni](https://wordpress.org/support/users/gioni/)
 * (@gioni)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/problems-when-using-phpmailer/#post-13392240)
 * WP Cerber doesn’t declare or load PHPMailer class. This class is declared in 
   and loaded by WordPress.
 *  Thread Starter [brainzilla](https://wordpress.org/support/users/brainzilla/)
 * (@brainzilla)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/problems-when-using-phpmailer/#post-13392545)
 * Thanks for the hint!
    And you are right – I need to change how I include the 
   mailer in my script.
 *  Thread Starter [brainzilla](https://wordpress.org/support/users/brainzilla/)
 * (@brainzilla)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/problems-when-using-phpmailer/#post-13401666)
 * This basically solved it for me:
    [https://wordpress.stackexchange.com/questions/344009/how-to-use-phpmailer-in-a-function-in-wordpress](https://wordpress.stackexchange.com/questions/344009/how-to-use-phpmailer-in-a-function-in-wordpress)
   Though I ended up using some globals to pass my parameters to PHPmailer, because
   of the bizarr way WP includes it all… (more elegant way would be to use closures).
 * Hope this helps anyone with similar problems.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems when using PHPmailer’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-cerber_77a9bf.svg)
 * [WP Cerber Security, Anti-spam & Malware Scan](https://wordpress.org/plugins/wp-cerber/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-cerber/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-cerber/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-cerber/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-cerber/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-cerber/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [brainzilla](https://wordpress.org/support/users/brainzilla/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/problems-when-using-phpmailer/#post-13401666)
 * Status: resolved