我从localhost发送邮件。我已经配置了php.ini和sendmail.ini。 我已经改变了php.ini文件,现在看起来像这样
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = ""D:\xampp\sendmail\sendmail.exe\" -t"\\I've removed the backslash coming before D n I get true but when I use with backslash then mail function return false
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the D:\xampp\mailoutput folder
;sendmail_path = "D:\xampp\mailtodisk\mailtodisk.exe"
sendmail.ini
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=587
auth_username=bsr.anwar@gmail.com
auth_password=********
php code
$subject = "Reset Password";
$message = "To reset your Password please go to <a href='localhost/task2/reset_password.php?email=$to&reset_token=$token'>localhost/task2/reset_password.php?email=$to&reset_token=$token</a>";
$headers = "From:bsr.anwar@gmail.com\r\n";
return mail($to, $subject,$message,$headers);
答案 0 :(得分:0)
使用PHPMailer插件.. https://github.com/PHPMailer/PHPMailer 它快速且易于使用。 您可以获得文档和教程here。