Hi guys, this is sowmithrii and new to this forum and also to php. i am smashing my head on solving one simple problem in php. and it is sending emails. i have used the mail() function and using XAMPP apache server.. i dont understant what the mistake was but unable to deliver the mail to the designated email address. -------------------------------------------------------------------- the sample code i have used: -------------------------------------------------------------------- $to= "you@yahoo.com"; $message = "Welcome to my site"; $subject = "Welcome!"; $headers = "From: "; $ok = @mail($to, $subject, $message, $headers); if($ok == TRUE) echo "Mail sent successfully"; else echo "unable to deliver the mail"; ---------------------------------------------------------------------- pls let me know the error why am not able to send the mail and i heard that some mails cannot be delivered to yahoo/ hotmail when they did it successfully for gmail. I will be happy if anyone gives me the correct code
Are you trying this code on your local machine. Have you configured SMTP on your machine? What is the error message you get?
actually am not getting any errors.. its just processing the code and just going on with the next statement after the mail function. i have even configured the SMTP. do i have to need any other mail server. i heard of phpmailer.. do this work. one more problem is ,, am not able to send mails to all the people i have mentions only 70% are getting mails and the remaining are not.
I also have this problem 3 years ago. I found following simple function to send emails. Actually you are not generating accurate mail headers that's why some mail servers are not accepting your emails. Mostly we have this header problem with hotmail. I am using this function from 3 years and no problem at all. function send_mail($myname, $myemail, $contactname, $contactemail,$subject, $message){ $headers =""; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html;\n\tcharset=\"iso-8859-1\"\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: MyMailer\n"; $headers .= "To: \"$contactname\" <$contactemail>\n"; $headers .= "From: \"$myname\" <$myemail>\n"; $headers .= "Reply-To: \"$myname\" <$myemail>\n"; return( mail( $contactemail, $subject, urldecode($message), $headers ) ); } PHP: