Member Avatar for starsinthesky

hi, i have a hard time testing my PHP mail() function in the localhost.
can you teach me? it's my first time to use this mail() function.

this is my PHP code in the file: contact.php

<?php
    $email_to = $_REQUEST['email_to'];
    $subject = "Re: FAQ Suggestion";
    $email =  "d26thletter@yahoo.com";
    $message = $_REQUEST['message'] ;
    $headers = "From: $email";
    $sent = mail($email_to, $subject, $message, $headers) ;
    if($sent)
    {print "Your mail was sent successfully"; }
    else
    {print "We encountered an error sending your mail"; }
    ?>

when i run it in the localhost, i got this error message:

SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\FAQ\contact.php on line 15
We encountered an error sending your mail

how could i make the mail() function work?

Recommended Answers

All 6 Replies

its becoz an email server is nt configured on your local machine...It wil work fine when u upload the file to the server....

Member Avatar for starsinthesky

how can i configure an email server to the local? thanks ahead.

thingking........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.