有一种简单的方法可以使用带有WAMP / XAMP的gmail SMTP服务器吗? 本地使用mail()

A lot of the posts I found were outdated. the php.ini file allows you to auth using:

auth_username auth_password

So I've tried using this in my php.ini:

SMTP = smtp.gmail.com
smtp_port = 465
auth_username = email@gmail.com
auth_password = password

restart wamp server, and nothing. I can't even debug it because it just hangs/I don't get a response to jquery ajax... php file:

$return = mail($to, $subject, $message, $headers);

echo $return;

js script:

btn.click( function() {
    jQuery.ajax( {
        type: "POST",
        url: form.attr( 'action' ),
        data: form.serialize(),
        success: function(data) {
            console.log(data);
            alert(data);
        }
    } );
} );

nothing comes back, the console doesn't even log one line, so it just hangs/never returns.

UPDATE: The php doesn't hang, it just takes a long time to timeout. and it says I failed to connect to smtp server. I just left the page there long enough for it to return.

not long before,I have the same problem as you!finally,I solve this with two methods. 1. using PHPMailer,you can see this post:http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/
2.you can try set the smtp in php script,using "ini_set()".