0

How would I send an email using the mail function on php with localhost(xampp)? My php.ini file is:

SMTP = smtp.gmail.com  
smtp_port = 465 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
sendmail_from = senders email

My sendmail.ini file is:

smtp_server=smtp.gmail.com
smtp_port=465 
error_logfile=error.log
debug_logfile=debug.log
auth_username=email address
auth_password=password
force_sender=sender's email

My code is:

$to_email = "email address";
$subject = "Subject";
$body = "msg";
$headers = "From: email address";

if (mail($to_email, $subject, $body, $headers)) {
    echo "Email successfully sent to $to_email...";
} else {
    echo "Email sending failed...";
}

0 Answers0