How to install php mail on debian 8 jessie
To install PHP mail on Debian 8 (Jessie), you can follow these steps:
Step 1: Update the package list
Run the following command to update the package list:
sudo apt-get update
Step 2: Install PHP
If you haven't already, install PHP on your Debian 8 system:
sudo apt-get install php5
Step 3: Install the PHP mail extension
Install the PHP mail extension (also known as php5-imap
):
sudo apt-get install php5-imap
Step 4: Configure PHP
Edit the PHP configuration file (/etc/php5/apache2/php.ini
) to enable the mail function:
sudo nano /etc/php5/apache2/php.ini
Find the following lines and uncomment them by removing the semicolon (;
) at the beginning:
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
Save and close the file.
Step 5: Restart Apache
Restart the Apache web server to apply the changes:
sudo service apache2 restart
Step 6: Test PHP mail
Create a PHP file (e.g., test.php
) with the following code:
<?php
mail('[email protected]', 'Subject', 'Hello, world!');
?>
Save the file and upload it to your web server.
Open a web browser and navigate to the URL of the PHP file. If everything is set up correctly, you should receive an email at the recipient's address.
That's it! You should now have PHP mail installed and working on your Debian 8 system.