How can XAMPP be configured to enable sending emails from a local server to external email addresses?
To enable sending emails from a local server using XAMPP, you need to configure the SMTP settings in the php.ini file. You can use a free SMTP service like Gmail to send emails from your local server. Update the php.ini file with the SMTP settings provided by your SMTP service provider, and then use the mail() function in PHP to send emails to external addresses.
// Set the SMTP settings in php.ini
ini_set("SMTP","smtp.gmail.com");
ini_set("smtp_port","587");
ini_set("sendmail_from","your_email@gmail.com");
ini_set("sendmail_path", "\"C:\xampp\sendmail\sendmail.exe\" -t");
// Send email using mail() function
$to = "recipient@example.com";
$subject = "Test Email";
$message = "This is a test email sent from XAMPP local server.";
$headers = "From: your_email@gmail.com";
mail($to, $subject, $message, $headers);
Related questions
-
email addresses sorting formatting
-
session_start headers output buffering
-
conditional statements PHP dynamic values