contra10 Posted February 21, 2009 Share Posted February 21, 2009 i'm testing mail on local host here is my coding that works <?php $headers = "From: me@worldnwired.com\r\n"; "To: $email"; "MIME-Version: 1.0\r\n"; "Content-Type: multipart/mixed;\r\n"; $body = "$username has added you as a friend"; mail("me@test.com","Friend Request",$body, $headers); ?> here is the coding when i want to change the send to the user <?php $friende= "SELECT * FROM `users` WHERE `username` = '$usernamef'"; $friendgetemail = mysql_query($friende) or die(mysql_error()); while ($friendemail = mysql_fetch_assoc($friendgetemail)) { $email = "{$friendemail['email']}"; } $headers = "From: me@worldnwired.com\r\n"; "To: $email"; "MIME-Version: 1.0\r\n"; "Content-Type: multipart/mixed;\r\n"; $body = "$username has added you as a friend"; mail($email,"Friend Request",$body, $headers); ?> the warning is Warning: mail() [function.mail]: SMTP server response: 500 please set from & to first... in C:\wamp\www\friendrequest\index.php on line 71 line 71 being mail($email,"Friend Request",$body, $headers); how do i echo the person's email instead of writting it in Quote Link to comment Share on other sites More sharing options...
contra10 Posted February 21, 2009 Author Share Posted February 21, 2009 $email should reflect the person that i'm sending it to. Quote Link to comment Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 echo $email. But your problem here is in your 'From' header. Try $headers from the mail function, and see if it works without that header. Quote Link to comment Share on other sites More sharing options...
contra10 Posted February 21, 2009 Author Share Posted February 21, 2009 i just tried it like that and it worked Quote Link to comment Share on other sites More sharing options...
jijodasgupta Posted February 21, 2009 Share Posted February 21, 2009 im gettin an error for my mail form wich i cant get rid off... Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\mailing\inc\lib\htmlMimeMail.php on line 680 configured my php.ini to [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = jijodasgupta@gmail.com even removed ; from php_smtp.dll file.... stil the same error.... Quote Link to comment Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 I don't think xamp has a built in smtp server, which means that you wont be able to send mails using it. You need an smtp server. I could be wrong though - never used xamp. Quote Link to comment Share on other sites More sharing options...
jijodasgupta Posted February 21, 2009 Share Posted February 21, 2009 ur rite...never knew this...thnx for d update...now lookin 4 an external smtp server to send my mail.... cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.