Hello all. I am sure my code is correct. But this mail function is not working on my site. On this site PHP Version 5.2.6 is install. when i run this code message is appear "Mail sent successfully!". But mail not sent. Please any one tell why mail function is not send mail. Please help me $to = $_POST[user_name]; $subject = 'Password Information '; $message = ' <p>Your Detail</p> <p> text here </p>'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Client<mail@abc.net>' . "\r\n"; // Mail it $msent=mail($to, $subject, $message, $headers); if(!$msent) { $error="Not Sent!"; } else { $error="Mail sent successfully!"; } Regards, Ronny
change to $message = "content here"; PHP: Next thing .. 3 times $header .. The same as I will say that 2 is equal to 3, 4 and 5 .. ! Please edit your post and paste everything from your file .. ( not only a part from it ).
Maybe the problem is not with your code. Check your mail server logs to see if the message was received for delivery, but perhaps failed for some other reason (DNS, queue issues, etc). Is this a linux/unix server? From your form try sending a message to a local user, maybe "root" or something. If that works the problem may be that you don't have your mail server configured correctly or maybe you have a firewall that is preventing this kind of outbound traffic?
Do you have shell access to this linux server via telnet or ssh or anything? If so, try this. I will assume your shell login is "LinksMaster". From the command line do: echo 'test' |mail LinksMaster --subject='test message' Code (markup): And then run "mail" from the command line with no options to see if you received the test message. If that works, have your form send mail to "LinksMaster" too and check with the mail command again to see if you received it. If so, your mail server just can't send mail out and you need to find out why. Also, were you able to check your mail logs yet? That will be a key indicator of where the problem is. If your hosting provider prevents your mail server from sending mail out, you may be able to use a custom function to send the mail to an external mail server (if you have one) and out from there.. i've used this code for such things before (i don't remember where i found it, but it works great!): function SendMail($ToName, $ToEmail, $FromName, $FromEmail, $Subject, $Body, $Header) { $SMTP = fsockopen("mail.externalmailserver.com", 25); $InputBuffer = fgets($SMTP, 1024); fputs($SMTP, "HELO userbars.com\n"); $InputBuffer = fgets($SMTP, 1024); fputs($SMTP, "MAIL From: $FromEmail\n"); $InputBuffer = fgets($SMTP, 1024); fputs($SMTP, "RCPT To: $ToEmail\n"); $InputBuffer = fgets($SMTP, 1024); fputs($SMTP, "DATA\n"); $InputBuffer = fgets($SMTP, 1024); fputs($SMTP, "$Header"); fputs($SMTP, "From: $FromName <$FromEmail>\n"); fputs($SMTP, "To: $ToName <$ToEmail>\n"); fputs($SMTP, "Subject: $Subject\n\n"); fputs($SMTP, "$Body\r\n.\r\n"); fputs($SMTP, "QUIT\n"); $InputBuffer = fgets($SMTP, 1024); fclose($SMTP); } Code (markup):
Thanks! you help me. But i have not shell excess . In this code i have not get any type of error .. How i find what is the problem behind the server Regards, Ronny