• Resolved inboundrocket

    (@inboundrocket)


    Hey fellow plugin coders ??

    one of the people using our plugin gets the following error:

    sendgrid: wp_mail has been declared by another process or plugin, so you won’t be able to use SendGrid until the conflict is solved.

    This is because in our code we’re using wp_mail to send out an email when a visitor converts to a lead. It seems this however is throwing this error together with the sendgrid plugin. Do you guys have some form of code available for other plugin authors to build in a check and if your plugin is installed that email is then being sent using the sendgrid code?

    A quick search online always bring me back to this forum, but not a concrete solution.

    Cheers!
    Hans from Inbound Rocket

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter inboundrocket

    (@inboundrocket)

    Is there anything available to assist other plugin builders to find a workaround for the problems caused with wp_mail?

    Apparently there is a Mandrill plugin out there that sort of gives the same error, but no real solution as well. Looking to have this fixed in our upcoming release ??

    Cheers!
    Hans

    Anonymous User 12640152

    (@anonymized-12640152)

    Thank you for providing this feedback.

    Unfortunately there is nothing we can do since WordPress does not provide functionality to be able to do this. If multiple plugins were allowed to override the wp_mail() function it would cause unexpected problems. At the very least you could be receiving multiple emails when you would send just one.

    As you can see, other plugins suffer from this as well. You can have only one plugin that overrides wp_mail() at any given time.

    We apologize for any inconvenience this caused and thank you for your patience with us.

    Thread Starter inboundrocket

    (@inboundrocket)

    Hey @team-rs, indeed and that is precisely the problem right now that I’m trying to fix.

    I’m pretty sure I’m not the first one who has this error because of the SendGrid plugin, how can your plugin work better together with other plugins to be able to prevent this issue?

    I’m looking for a way to check if your plugin is installed, activated and used for sending email so that instead of using wp_mail the emails are then routed through your plugin.

    Cheers!
    Hans

    Anonymous User 12640152

    (@anonymized-12640152)

    Hello.

    Since this plugin is used to send email we absolutely need to override the wp_mail function. We cannot work around that. Plugins that only enhance the content of emails (e.g. templates) should use filters to do this, not override the function. We need to do this in order to prevent the email being sent the normal way and send it via the API or SMTP. On some servers sending emails the normal way causes errors because of restrictions from the hosting provider.

    We want to clarify further. wp_mail is a pluggable function as noted here in the official WordPress Documentation: https://codex.www.ads-software.com/Pluggable_Functions

    The Note from that documentation states:
    “A function can only be reassigned this way once, so you can’t install two plugins that plug the same function for different reasons. For safety, it is best to always wrap your functions with if (?!function_exists() ), otherwise you will produce fatal errors on plugin activation.”

    As such, this check exists in our plugin and we will display an error if wp_mail is already reassigned. If we do not do this, installing the plugin will break your website.

    As you yourself have stated, there are several plugin authors that experience the same issue. There is no possible workable solution if more than one plugin tries to take ownership of wp_mail.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘sendgrid: wp_mail has been declared by another process or plugin’ is closed to new replies.