How to enble php mailing in cpanel server

Enabling PHP mailing on a cPanel server involves a few steps. Here's a step-by-step guide to help you do so:

Step 1: Check if PHP mailing is disabled

Log in to your cPanel account and navigate to the "Software" section. Click on "Select PHP Version" and check if the "mail" extension is disabled. If it is, you'll need to enable it.

Step 2: Enable the mail extension

To enable the mail extension, follow these steps:

  1. Log in to your cPanel account and navigate to the "Software" section.
  2. Click on "Select PHP Version" and select the version you're currently using (e.g., PHP 7.4).
  3. Click on the "Configure PHP" button.
  4. Scroll down to the "PHP Extensions" section.
  5. Look for the "mail" extension and toggle the switch to the "On" position.
  6. Click the "Save" button to save your changes.

Step 3: Configure the mail settings

To configure the mail settings, follow these steps:

  1. Log in to your cPanel account and navigate to the "Email" section.
  2. Click on "Email Accounts" and select the email account you want to configure.
  3. Click on the "Settings" button next to the email account.
  4. Scroll down to the "Mail Server Settings" section.
  5. Update the following settings:
    • "Mail Server": Select the mail server you want to use (e.g., "mail.yourdomain.com").
    • "Username": Enter the email account username.
    • "Password": Enter the email account password.
    • "Port": Enter the port number (e.g., 25, 587, or 465).
    • "Encryption": Select the encryption method (e.g., "TLS" or "SSL").
  6. Click the "Save" button to save your changes.

Step 4: Test the PHP mailing

To test the PHP mailing, you can use a simple PHP script like this:

<?php
mail('[email protected]', 'Subject', 'Hello, this is a test email!');
?>

Replace [email protected] with the email address you want to send the email to, and Subject and Hello, this is a test email! with the subject and body of the email, respectively.

Save the script as a PHP file (e.g., testmail.php) and upload it to your website's root directory. Then, access the script by visiting http://yourdomain.com/testmail.php in your web browser. If the email is sent successfully, you should receive it in your email account.

That's it! If you've followed these steps, you should now be able to send emails using PHP on your cPanel server.