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
- Open the
php.ini
file in a text editor. You can find it in theC:\wamp\bin\php\php5.6.25
directory (or the equivalent directory for your PHP version). - 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. - Save the changes to the
php.ini
file.
Step 2: Install Pear
- Open a command prompt or terminal window.
- Navigate to the
C:\wamp\bin\php\php5.6.25
directory (or the equivalent directory for your PHP version). - 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
- 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
- Create a new PHP file (e.g.,
test.php
) in theC:\wamp\www
directory (or the equivalent directory for your web root). - 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.