Troubleshoot the WordPress Error: “wp_mail has been declared by another plugin or theme”

The Error

The following error tends to appear when activating or updating a plugin from the WordPress plugin panel:

wp_mail has been declared by another plugin or theme

or, perhaps:

“Postman: wp_mail has been declared by another plugin or theme, so you won’t be able to use Postman until the conflict is resolved.
More info that may help – /path/to/home/wp-includes/pluggable.php:174”

Cause

While the error notification states “plugin or theme,” it is uncommon for the active WordPress theme to be the cause. In the following it is assumed that conflicting plugins are the root cause.

Somewhere, mostly likely in one of the activated plugins, the function wp_mail () has already been declared as a function, so it cannot be redeclared in a second plugin. Typically, the error will be thrown by the SMTP plugin in use on your site to process transactional emails (for example, form submissions, WordPress alerts, plugin notifications, etc.).

You may wish to review wp_mail () in the WordPress Developer Resources documentation.

Troubleshooting: Process of Elimination

As the error is mostly likely caused by a pair of conflicting plugins, the troubleshooting process is to systematically deactivate each plugin in the site until the conflicting pair of plugins can be isolated.

  1. Because troubleshooting involves deactivating plugins that may be crucial to the function of the site, it is best to conduct troubleshooting on a copy of your site moved to a staging or development server. If this is not possible consider undertaking testing during a period of low traffic or during off-hours and make sure to have a recent backup available.
  2. If you have a SMTP plugin installed, deactivate it and note if the conflict alert/error disappears. Typically, it is an SMTP plugin that will generate the error when another plugin is stopping it from functioning properly.
  3. If the error disappears, reactivate the SMTP plugin and start deactivating other plugins until the conflict alert disappears again.
  4. Continue deactivating the remaining plugins until only the SMTP plugin is active.
  5. Now reactivate the plugins, excluding the second plugin that appeared to trip the error. This will eliminate the possibility of a third plugin contributing to the error.
  6. Finally, reactivate the second plugin you identified as causing the error. The error should then reappear.

At this point, since the issue has been narrowed to two plugins, consider one of the following options:

  1. Consider temporary removal and replacement of the conflicting plugin.
  2. Communicate with the developers of both plugins to see if a fix is available.

Troubleshooting: Code Inspection

If process of elimination fails to isolate the conflicting plugin, you can attempt to inspect the code of the site’s various plugins.

Working from a backup of the site, you can use Visual Studio Code or similar tool capable of searching the code of all the files in the plugin directory (/wp-content/plugins).

Search for wp_mail or wp_mail ().

You will likely find wp_mail in many locations within the code of the installed plugins.

Those without wp_mail can likely be removed from consideration as a possible cause.

The mere presence of wp_mail in a plugin’s code does not necessarily mean it is the cause of the conflict. In most cases wp_mail will be used properly. In order for a conflict to arise a function needs to be declared using wp_mail (), for example function wp_mail (). If you are capable of reviewing the related PHP code, look for that type of usage or something equivalent. Either way this approach will at least eliminate a number of installed plugins as a possible source of the issue.

Alternatives

If the error is being generated by an SMTP plugin, and you cannot locate the conflict or require the second plugin that is causing the conflict, you might try using a different SMTP plugin.

Some common options are:

Report Findings to the Plugin Developer

If you are able to isolate the cause of the conflict, be sure to report the issue to the developer of the conflicting plugin. If they are able to issue a patch, you save many others from a similar issue!

Thoughts?

I’d love to hear if you have solved this issue with another method. Drop me a comment below. Thanks!

Vance Bell

Vance Bell

Hi there, glad you made it! I’m Vance Bell, a freelance web designer/developer and frequent marketing consultant.

Monday to Saturday I help businesses and organizations grow attention and revenue. Sometimes on Sunday I take a break and binge watch Netflix.

Owner of Pixel Engine, a Philadelphia-based web design and online marketing studio.

If you’d like to hire me, I’d love to hear from you. If you just have a question, feel free to ask.

Related Posts

Leave a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

Scroll to Top