943,838 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 6135
  • PHP RSS
Apr 30th, 2009
0

test PHP mail() in localhost

Expand Post »
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 Syntax (Toggle Plain Text)
  1. <?php
  2. $email_to = $_REQUEST['email_to'];
  3. $subject = "Re: FAQ Suggestion";
  4. $email = "d26thletter@yahoo.com";
  5. $message = $_REQUEST['message'] ;
  6. $headers = "From: $email";
  7. $sent = mail($email_to, $subject, $message, $headers) ;
  8. if($sent)
  9. {print "Your mail was sent successfully"; }
  10. else
  11. {print "We encountered an error sending your mail"; }
  12. ?>

when i run it in the localhost, i got this error message:
PHP Syntax (Toggle Plain Text)
  1. SMTP server response: 553 We do not relay non-local mail, sorry. in C:\xampp\htdocs\FAQ\contact.php on line 15
  2. We encountered an error sending your mail

how could i make the mail() function work?
Reputation Points: 10
Solved Threads: 0
Light Poster
starsinthesky is offline Offline
38 posts
since Jan 2009
Apr 30th, 2009
0

Re: test PHP mail() in localhost

its becoz an email server is nt configured on your local machine...It wil work fine when u upload the file to the server....
Reputation Points: 1
Solved Threads: 2
Light Poster
shefeekj is offline Offline
37 posts
since Apr 2009
Apr 30th, 2009
0

Re: test PHP mail() in localhost

how can i configure an email server to the local? thanks ahead.
Reputation Points: 10
Solved Threads: 0
Light Poster
starsinthesky is offline Offline
38 posts
since Jan 2009
Apr 30th, 2009
0

Re: test PHP mail() in localhost

You'll have to use your isp's SMTP server.
See here:http://roshanbh.com.np/2007/12/sendi...vironment.html
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Apr 30th, 2009
0

Re: test PHP mail() in localhost

It depends on what OS you are running on.

Based off of the question, I'll assume you are running windows.

Buddylee17 had a great link.

On windows, I use stunnel that connects to sendmail http://www.google.com/search?q=php+s...ient=firefox-a
Reputation Points: 34
Solved Threads: 51
Posting Whiz
kireol is offline Offline
305 posts
since Mar 2008
Apr 30th, 2009
0

Re: test PHP mail() in localhost

I agree with "shefeekj" you should configure your mail server. If you see Windows, I just wanna suggest you to follow these step using ArgoSoft:
http://www.phpeasystep.com/phptu/23.html

Good luck, buddy
Reputation Points: 10
Solved Threads: 1
Newbie Poster
sch_bern is offline Offline
5 posts
since Mar 2009
Apr 30th, 2009
0

Re: test PHP mail() in localhost

thingking........
Reputation Points: 10
Solved Threads: 1
Newbie Poster
nhocikaka is offline Offline
3 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: arrays checkboxes, Form submit array
Next Thread in PHP Forum Timeline: MySQL and Apache





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC