How do I send email with XAMPP?

To send email with XAMPP, you can use the built-in PHP mail function. Here are the steps you can follow:

Open the XAMPP control panel and start Apache and MySQL.

Open a text editor and create a new PHP file. Save the file with a .php extension, such as "send-email.php".

In the PHP file, add the following code to send an email:

<?php

$to = "recipient@example.com";

$subject = "Test email";

$message = "This is a test email sent from XAMPP.";

$headers = "From: sender@example.com";


mail($to, $subject, $message, $headers);

?>

Make sure to replace the email addresses with the appropriate values for the sender and recipient.

Save the PHP file and place it in the htdocs folder in the XAMPP installation directory.

Open a web browser and navigate to "http://localhost/send-email.php" (or whatever you named your PHP file).

If the email was sent successfully, you should see a message indicating that the email was sent. If there were any errors, you should see an error message.

Note that sending email with the PHP mail function requires a working mail server. If you're testing locally with XAMPP, you may not have a mail server set up. In that case, you can use a tool like Mailtrap (https://mailtrap.io/) to simulate a mail server and test sending email.

Previous Post Next Post