Jump to content

PHP Mailing Code not functioning


ritwick

Recommended Posts

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 = '[email protected]';

$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.

Link to comment
https://forums.phpfreaks.com/topic/72373-php-mailing-code-not-functioning/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.