How to enable php mail function on plesk

Enabling the PHP mail function on Plesk can be a bit tricky, but I'll guide you through the process. Here are the steps:

Step 1: Check if PHP mail is disabled

First, check if PHP mail is disabled by default in your Plesk installation. You can do this by creating a simple PHP file with the following code:

<?php
phpinfo();
?>

Upload this file to your website's root directory and access it in your browser. Look for the "mail" section in the PHP information output. If it says "Disabled" or "Not Installed", then you need to enable it.

Step 2: Enable PHP mail in Plesk

To enable PHP mail, you'll need to configure the mail settings in Plesk. Here's how:

  1. Log in to your Plesk control panel.
  2. Go to Settings > Mail > Mail Settings.
  3. Click on the PHP Mail tab.
  4. Select the Enable PHP Mail checkbox.
  5. Choose the mail server you want to use (e.g., your Plesk server's mail server or an external mail server).
  6. Enter the mail server's hostname or IP address, and the port number (usually 25).
  7. Click OK to save the changes.

Step 3: Configure PHP settings

Next, you need to configure the PHP settings to allow the use of the mail function. Here's how:

  1. Go to Settings > PHP Settings.
  2. Click on the PHP Settings tab.
  3. Look for the sendmail_path setting and enter the path to your mail server's sendmail executable (e.g., /usr/sbin/sendmail).
  4. Click OK to save the changes.

Step 4: Test the PHP mail function

Create a new PHP file with the following code:

<?php
mail('[email protected]', 'Subject', 'Hello, world!');
?>

Upload this file to your website's root directory and access it in your browser. If the PHP mail function is working correctly, you should receive an email at the specified recipient's address.

That's it! If you encounter any issues or errors during the process, feel free to ask, and I'll do my best to help you troubleshoot.