/    Sign up×
Community /Pin to ProfileBookmark

not able to send mails

Plz check why this code doesnt working, as i am new to PHP , so it is very tough to me to find Error.

Even after submitting thank you message doesn’t comes .

Why?

plz see the code below

<?php
//echo “<pre>”;
//print_r($_POST); // will print all the forms fields

$prefix=$_POST[“Title”];
$fname=$_POST[“First_Name”];
$mname=$_POST[“Middle_Name”];
$lname=$_POST[“Last_Name”];
$designation=$_POST[“Designation”];
$cname=$_POST[“Company_Name”];
$cwebaddress=$_POST[“Company_Website”];
$address=$_POST[“Company_Address”];
$pin=$_POST[“pincode”];
$phno=$_POST[“phone”].”#”.$_POST[“extn”];
$mobile=$_POST[“Mobile”];
$email=$_POST[“email”];
$State=$_POST[“State”];
$fax=$_POST[“Fax_No”];
$dob=$_POST[“dob”];
$Anniversary_date=$_POST[“doa”];

//”””””””””””””””””””””””””””””””””””””””””””””
$to = “[email protected]”;
$from = “[email protected]”;
$headers = “MIME-Version: 1.0rn”;
$headers.= “Content-type: text/html; charset=iso-8859-1rn”;
$headers.= “From: $fromrn”;
// Additional headers

$headers .= ‘To: ‘ .$to. “rn”;
$headers .= ‘From: ‘ .$from. “rn”;
$subject = ‘Info rec from ‘.$email;

//$headers .= ‘Cc: [email][email protected][/email]’ . “rn”;
//$headers .= ‘Bcc: [email][email protected][/email]’ . “rn”;

$message = “<html>
<head></head>
<body>
<table cellspacing-‘0′ cellpadding=’0′ width=’100%’ border=’1′>
<tr valign=’top’>
<td width=’300′><b>Prefix</b> </td>
<td width=’20’></td>
<td>”.$prefix.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Name</b> </td>
<td width=’20’></td>
<td>”.$fname.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Middle</b> </td>
<td width=’20’></td>
<td>”.$mname.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>last name </b> </td>
<td width=’20’></td>
<td>”.$lname.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Designation </b> </td>
<td width=’20’></td>
<td>”.$designation.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Company Name </b> </td>
<td width=’20’></td>
<td>”.$cname.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Comapany WebSite </b> </td>
<td width=’20’></td>
<td>”.$cwebaddress.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Phone</b> </td>
<td width=’20’></td>
<td>”.$phno.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Pincode</b> </td>
<td width=’20’></td>
<td>”.$pin.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Email</b> </td>
<td width=’20’></td>
<td>”.$email.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Fax No</b> </td>
<td width=’20’></td>
<td>”.$fax.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Address</b> </td>
<td width=’20’></td>
<td>”.$address.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Mobile No</b> </td>
<td width=’20’></td>
<td>”.$Mobile.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>State</b> </td>
<td width=’20’></td>
<td>”.$State.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Date of Birth</b> </td>
<td width=’20’></td>
<td>”.$dob.”</td>
</tr>
<tr><td colspan=’3′>&nbsp;</td></tr>
<tr valign=’top’>
<td width=’300′><b>Anniversary Date</b> </td>
<td width=’20’></td>
<td>”.$Anniversary_date.”</td>
</tr>

</table>
</body>
</html>
“;

$iMail = mail($to, $subject, $message, $headers);
if($iMail){

echo “<center><img src=’http://corporatepages.in/images/outdoor%20logo%20copy.jpg’ alt=’Welcome to outdoornetwork.in’ width=’150′ height=’85’ /><br><br><em><strong>We thank you for your time.</strong></em></center>”;

}else{
echo “<center><font color=’red’><b>Error – Mail could not be send !</b></font></center>”;
}

// writing data to excel file

$data=”n”.$prefix.”,”.$fname.”,”.$mname.”,”.$lname.”,”.$designation.”,”.$cname.”,”.$cwebaddress.”,”.$address.”,”.$annualadspend.”,”.$phno.”,”.$mobile.”,”.$email.”,”.$State.”,”.$fax.”,”.$dob.”,”.$Anniversary_date.”,”.date(“F j, Y, g:i a”);
$driver=fopen(‘data.csv’,’a’);
fwrite($driver,$data);
fclose($driver);
//echo(“<br><center><font color=’red’><b>Data Submitted !</b></font></center>”);

//writing data into database

require_once(“connect.php”);
$query=”insert into mailinfo values(‘”.rand().”‘,'”.$fname.”‘,'”.$mname.”‘,'”.$lname.”‘,'”.$designation.”‘,'”.$cname.”‘,'”.$cwebaddress.”‘,'”.$address.”‘,'”.$annualadspend.”‘,'”.$phno.”‘,'”.$mobile.”‘,'”.$email.”‘,'”.$State.”‘,'”.$fax.”‘,'”.$dob.”‘,'”.$Anniversary_date.”‘,'”.date(‘F j, Y, g:i a’).”‘)”;
mysql_query($query)or die (mysql_error());

echo “<center><img src=’http://corporatepages.in/images/outdoor%20logo%20copy.jpg‘ alt=’Welcome to outdoornetwork.in’ width=’150′ height=’85’ /><br><br><em><strong>We thank you for your time.</strong></em></center>”;

?>
[B]:confused: :confused: [/B]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @lohumihem spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...