无法在使用Gmail SMTP配置的localhost XAMPP上发送邮件

时间:2014-12-19 08:20:33

标签: php apache email smtp xampp

我无法在localhost上发送邮件。

以下是XAMPP中的Gmail设置>>的php.ini

[mail function]

; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
 SMTP = smtp.gmail.com
 smtp_port = 465
 username = user@gmail.com
 password = pass

; For Win32 only.
; http://php.net/sendmail-from
 sendmail_from = user@gmail.com

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.  
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
; sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

以下是邮件代码:

<?php
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: user@gmail.com' . "\r\n";

$result = mail('user@gmail.com', 'Test Mail', 'Please ignore! This is a test message.', $headers);
print_r($result); die;
?>

$result我得到1

0 个答案:

没有答案