我如何使用localhost(xampp)在php上使用mail函数发送电子邮件? 我的php.ini文件是:
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
sendmail_from = senders email
我的sendmail.ini文件是:
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
我的代码是:
$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...";
}