Email Setup Center
  • Home »
  • Mail Function issue in Php 

How To Fix Mail Function Error in Php? 

If your PHP mail function fails to work or if it displays an error message mail function error in Php, then you are in a situation to engage in troubleshooting. Check the spam folder first, because if your message is not reaching the recipient’s inbox, then it is essential to update the spam filter of the recipient. Another important thing is that you need to check your inbox for bounce-back messages. Send a php test mail using simple php mail tester commands and wait for the result. If you find that everything is okay, then the problem is with the SMTP server settings. Make sure that your firewall settings are disabled temporarily to prevent blockage issues.

Solution: 1 - To install and configure a new SMTP server on your computer

  • If you are using a Windows desktop, proceed with the below-mentioned steps.
  • Download a free email server such as hMailServer from the Internet.
  • After downloading the SMTP server, install it on your Windows and enable the SMTP protocol.
  • If necessary, remove all the SMTP authentication except the SMTP server.
  • If you are using a Linux computer, install either sendmail or Postfix using Terminal.
  • In the Terminal window, type the “sudo apt-get install sendmail” command and press Enter.
  • Otherwise, type the “sudo apt-get install postfix” command and press the Enter key to install the SMTP server.
  • If you have already installed the SMTP server, change the existing PHP configuration file settings to its original server ad then fix the mail function error in Php(for example, Gmail accounts can be pointed to Gmail SMTP server).

Solution: 2 – Enabling the authentication

  • Open the Gmail web interface and access your Gmail account with your login credentials.
  • Go to Security Settings and enable 2-step authentication.
  • You might need a phone to get the verification code for the created app password.
  • Choose PHP Mailer as the app you wish to generate the app password.
  • Note down the 16-digit code and use it on your PHP mail function to resolve the mail function error in Php.
mail function error in Php