We help IT Professionals succeed at work.

Mail in PHP with XAMPP on localhost (windows)

322 Views
Last Modified: 2015-06-30
Hi,

I am trying to set up mailing using php on my localhost.  
I am not really quite aware what my options are, but a quick search found me sendmail.exe (which hasnt been updated for years, but is included with XAMPP)

Currently, this is what I have :


text.php :
    $to      = 'aaa@gmail.com';
    $subject = 'About localhost';
    $message.="Please...let this work";
    $headers = 'From: xxx@gmail.com' . "\r\n" .
        'Reply-To: xxx@gmail.com' . "\r\n";
    $headers.= "MIME-Version: 1.0\r\n";
    $headers.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $headers.= 'X-Mailer: PHP/' . phpversion();
    try {
        mail($to, $subject, $message, $headers);
        echo("hihihihihihi");
    }
    catch (mysqli_sql_exception $e){
        echo ("hahahahahaha");
        echo "well this didnt work out" . $e;
    }

Open in new window



php.ini :

SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off

sendmail.ini :

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
auth_username=xxx@gmail.com
auth_password=xxx
pop3_server=
pop3_username=
pop3_password=
force_sender=xxx@gmail.com
force_recipient=
hostname=smtp.gmail.com


I have also modified the properties of sendmail.exe so that it is running under administrative mode, with compatibility setting for windows xp sp 3

The result I am getting on the page is as follows

UAC opens up, requesting permission to run sendmail.exe
once I give the permission, sendmail.exe opens up a blank command prompt window
The website keeps loading, waiting for some sort of response from sendmail.exe.

Then nothing happens. The sendmail.exe command prompt never changes.

Any suggestions?
Or maybe a different solution to sendmail?

Thank you
Comment
Watch Question

Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
For what it's worth, Gmail has changed their login authentication and you will not be able to use that code to connect to Gmail.
Thanks, Dave. Any recommendation on what I need to use/do?
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Thanks Dave.
I am keeping the thread alive for a little longer, hoping someone can give me a way to make sending mail using localhost with xampp on windows to work .
So setting up mercury mail server to send mail to thunderbird works. I dont think this can work for other online email, but at least it lets me tests that my code works before i ever have to upload my files to the server.

http://system66.blogspot.ca/2010/01/how-to-send-mail-from-localhost-with.html
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Graham N.Group MD
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Going to award points to a new comment.
Thanks guys!

For now, the mercury solution worked. I have spent a day and a half trying sendmail.exe and phpmailer to work to no avail for me through gmail, for something that should work flawlessly if i had done this through a real server, and not a windows localhost one. So i'll keep the suggestion with hmail at the back of my mind for my next project.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.