PHP -使用xampp localhost发送邮件


PHP - sending mail using xampp localhost

我正在尝试使用xampp发送到gmail。

我的PHP版本是5.6.8

使用此来源作为指南,我改变了我的php.ini和sendmail.ini的配置,但它不适合我。页面总是显示失败:邮件未发送!

这是我的php:
$to      = 'kennybanny12@gmail.com';
$subject = 'No subject';
$message = 'Hello, this is the content of the email.';
$headers = 'From: sticollegesocial@gmail.com';
if(mail($to, $subject, $message, $headers)) {
    echo 'Email sent successfully!';
} else {
    die('Failure: Email was not sent!');
}
这些是我在php.ini中修改的
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = sticollegesocial@gmail.com
sendmail_path = "'"C:'xampp'sendmail'sendmail.exe'" -t"

sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=sticollegesocial@gmail.com
auth_password=**********
force_sender=sticollegesocial@gmail.com

看起来你很努力,但那篇文章不包含作者。请查看这个链接。