Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i am using Xampp on windows 7 and i am trying to send a mail using php mail() function to my gmail. (without using libraries like Phpmailer)

i have tried using:

  1. Mercury Mail - The script is not showing any errors and the mail() function actually returns true

  2. Test Mail Server Tool - same issue as mercury mail

  3. Fake Send mail - getting a "Connect timed out" error.

These are my settings for Fake Send Mail :

sendmail.ini

smtp_server=smtp.gmail.com
smtp_port=587  (tried using 465)
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=pass

php.ini

sendmail_path = "\"E:\xampp\sendmail\sendmail.exe\" -t" has been commented out

This is my code:

<?php

$to      = '[email protected]';
$subject = 'the the';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

This is result of telnet smtp.gmail.com 587 :

220 mx.google.com ESMTP sb3sm19649093pac.14 - gsmtp
451 4.4.2 Timeout - closing connection. sb3sm19649093pac.14 - gsmtp
Connection to host lost.

i have gone through similar questions in this forum but it's still not working for me.

What is it that i am missing here and could you provide me the links for any other tools that i should try? Thanks..

share|improve this question
add comment

1 Answer

You should not use the mail command, its quite unstable on windows and should in fact not even be used on Linux. You should use the PHPMailer Class by Worx of PHPMailerLite class. This connects to the SMTP Server.

It's giving you a lot of extra options. You should try implementing the PHPMailer class for you own sake!

share|improve this answer
 
phpmailer is working for me... what i wanted to know was why the mail() function is not working –  depz123 Jun 30 at 19:17
 
Probably because the windows sendmail wont authenticate on smtp, and is not able to connect to secure smtp servers. Which gmail is required to connect through. –  Benjamin De Bos Jun 30 at 19:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.