ritwick Posted October 8, 2007 Share Posted October 8, 2007 Hi ppl, Here is my PHP code receiving data from a html form. It is supposed to mail the data. But there seems to be some problem. Thanks in advance PHP CODE <?php $to = 'ritwickpal@gmail.com'; $subject = 'Website Query'; $cname =($_POST["dname"]); $cmail =($_POST["dmail"]); $message = '<html><head><title>website Query</title></head><body>'; $message.= '<table width="80%" border="2" align="center" style="WORD-BREAK:BREAK-ALL;">'; $message.= '<tr><td bgcolor="CEE7FF" width="40%"><strong>Name</strong></td><td width="*"> '.$cname.'</td></tr>'; $message.= '<tr><td bgcolor="CEE7FF" width="40%"><strong>Email</strong></td><td width="*"> '.$cmail.'</td></tr>'; $message.= '</table>'; $message.='</body></html>'; $headers = 'From: '.$cmail. "\r\n"; $headers .= 'To: '.$to. "\r\n"; $headers .= 'MIME-Version: 1.0'. "\r\n"; $headers .= 'charset=iso-8859-1'. "\r\n"; $headers .= 'Content-type: text/html;'. "\r\n"; //$headers .= 'boundary="'.$mime_boundary.'"'. "\r\n"; print 'TO: '.$to.'<br>'; print 'SUBJECT: '.$subject.'<br>'; print 'MESSAGE: '.$message.'<br>'; print 'HEADER: '.$headers.'<br>'; if(!mail($to,$subject,$message,$headers)) { print '<font color="red">Unsuccessful</font>'; } else { //print "<script>"; //print "self.location='index.html';"; //print "</script>"; print 'message sent<br><br>'; } ?> It prints Unsuccessful every time. Quote Link to comment https://forums.phpfreaks.com/topic/72373-php-mailing-code-not-functioning/ 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.