How to install pear mail package in wamp

To install the Pear Mail package in WAMP, you'll need to follow these steps:

Step 1: Enable the Pear extension in PHP

  1. Open the php.ini file in a text editor. You can find it in the C:\wamp\bin\php\php5.6.25 directory (or the equivalent directory for your PHP version).
  2. Search for the line that starts with extension=php_pear.dll. If it's commented out (starts with a semicolon), remove the semicolon to enable it.
  3. Save the changes to the php.ini file.

Step 2: Install Pear

  1. Open a command prompt or terminal window.
  2. Navigate to the C:\wamp\bin\php\php5.6.25 directory (or the equivalent directory for your PHP version).
  3. Run the following command to install Pear:
    pear install pear/pear

    This may take a few minutes to complete.

Step 3: Install the Mail package

  1. Once Pear is installed, you can install the Mail package using the following command:
    pear install mail

    This will install the Mail package and its dependencies.

Step 4: Verify the installation

  1. Create a new PHP file (e.g., test.php) in the C:\wamp\www directory (or the equivalent directory for your web root).
  2. Add the following code to the file:
    
    <?php
    require_once 'Mail.php';

$mail = Mail::factory('smtp', array( 'host' => 'smtp.example.com', 'port' => 25, 'auth' => true, 'username' => 'your_email_username', 'password' => 'your_email_password' ));

$mail->send('[email protected]', 'Subject', 'Hello, world!'); ?>


Replace the placeholders with your actual email settings.

3. Save the file and open it in a web browser. If everything is installed correctly, you should see a success message.

That's it! You should now have the Pear Mail package installed and working in your WAMP environment.