Search code examples
phpwordpressamazon-ec2phpmailer

Wordpress PHPMailer - Mailer Error: Could not instantiate mail function


I have a Wordpress site that sends email to the users via PHPMailer. It worked properly on staging server so far but after production deployment (different server), it stopped working. I get this error response from the mailer:

Mailer Error: Could not instantiate mail function

Is this something related to the server configuration? Staging is running on PHP v7.2.x and Production is running on PHP v7.4.x. Both sites are hosted on AWS EC2 instances.


Solution

  • The first place you look should be the docs. As that says, this error is usually due to you not having a local mail server installed.

    You can solve this either by installing and configuring a mail server on your host, or by altering your mailing config so that it sends directly through some other host (e.g. gmail), so long as your hosting provider allows you to do that (see other notes in the guide).