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: [email protected]\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 protected]","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: [email protected]\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 Link to comment https://forums.phpfreaks.com/topic/146256-solved-email-error/ 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. Link to comment https://forums.phpfreaks.com/topic/146256-solved-email-error/#findComment-767808 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. Link to comment https://forums.phpfreaks.com/topic/146256-solved-email-error/#findComment-767817 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 Link to comment https://forums.phpfreaks.com/topic/146256-solved-email-error/#findComment-767818 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 = [email protected] even removed ; from php_smtp.dll file.... stil the same error.... Link to comment https://forums.phpfreaks.com/topic/146256-solved-email-error/#findComment-767836 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. Link to comment https://forums.phpfreaks.com/topic/146256-solved-email-error/#findComment-767862 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 Link to comment https://forums.phpfreaks.com/topic/146256-solved-email-error/#findComment-767876 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.