Below php code:
<?php
/*print_r($_POST);
print_r($_FILES);
exit;*/
if(isset($_POST['txt_firstname']))
{
$firstname=$_POST['txt_firstname'];
$lastname=$_POST['txt_lastname'];
$email=$_POST['txt_email'];
if($firstname== ” || $lastname== ” || $email==”)
{
echo “You should Enter the required fields”;
}
elseif($_FILES['txt_resume']['name']==”")
{
$toaddress = $email;
$subject = “Your homework submission!”;
$firstname=$_POST['txt_firstname'];
$lastname=$_POST['txt_lastname'];
$email=$_POST['txt_email'];
$message=$_POST['message'];
// message
$message = ”
<html>
<head>
<title>Sarika</title>
</head>
<body>
<table>
<tr>
<td>Dear $firstname</td>
</tr>
<tr>
<td>Your details,</td>
</tr>
<tr>
<td><b>First Name:<b> $firstname</td>
</tr>
<tr>
<td><be>Last Name:<b> $lastname</td>
</tr>
<tr>
<td><be>Message:<b>”. nl2br($message).”</td>
</tr>
<tr>
<td>Email: $email</td>
</tr>
<tr>
<td>Regards</td>
</tr>
<tr>
<td>ADMIN jaybharatjay@gmail.com</td>
</tr>
</table>
</body>
</html>
“;
$headers = “MIME-Version: 1.0rn”;
$headers .= “Content-type: text/html; charset=iso-8859-1rn”;
$headers .= “To: $row[emails] <$row[emails]>rn”;
$headers .= “From: tutorial moonreturn.com Mailing System <$email>rn”;
$headers .= “Cc: jaybharatjay@yahoo.co.inrn”;
$headers .= “Bcc: jaybharatjay@gmail.comrn”;
$success = @mail($toaddress,$subject,$message,$headers)or
die(‘<br><strong>Unfortunately, your message could not be delivered.<br>Please Check Localhost or Website</strong>’);
if ($success)
{
// Redirect to thank you page.
Header(“Location: thanks.php”);
}
}
else
{
//Attach mail sending start
$uploaddir = ‘attachmentsTemp/’;
$uploadfile = $uploaddir . basename($_FILES['txt_resume']['name']);
if (move_uploaded_file($_FILES['txt_resume']['tmp_name'], $uploadfile))
{
$fileatt = $uploadfile;
$fileatt_type = “application/octet-stream”;
$fileatt_name = basename($_FILES['txt_resume']['name']);
$email_from = “jaybharatjay@gmail.com”;
$email_subject = “jay attach mail testing/tutorial”;
$email_txt = “This is testing mail attach sending”;
$email_to = $_REQUEST[txt_email];
$headers = “From: “.$email_from;
$file = fopen($fileatt,’rb’);
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = “==Multipart_Boundary_x{$semi_rand}x”;
$headers .= “nMIME-Version: 1.0n” .
“Content-Type: multipart/mixed;n” .
” boundary=”{$mime_boundary}”";
$toaddress = $email;
$subject = “Your homework submission!”;
$firstname=$_POST['txt_firstname'];
$lastname=$_POST['txt_lastname'];
$email=$_POST['txt_email'];
$message=$_POST['message'];
$email_message .= ”
<html>
<head>
<title>Sarika</title>
</head>
<body>
<table>
<tr>
<td>Dear $firstname</td>
</tr>
<tr>
<td>Your details,</td>
</tr>
<tr>
<td><b>First Name:<b> $firstname</td>
</tr>
<tr>
<td><be>Last Name:<b> $lastname</td>
</tr>
<tr>
<td><be>Message:<b> nl2br($message)</td>
</tr>
<tr>
<td>Email: $email</td>
</tr>
<tr>
<td>Regards</td>
</tr>
<tr>
<td>ADMIN jaybharatjay@gmail.com</td>
</tr>
</table>
</body>
</html>
“;
$email_message .= “This is a multi-part message in MIME format.nn” .
“–{$mime_boundary}n” .
“Content-Type:text/html; charset=”iso-8859-1″n” .
“Content-Transfer-Encoding: 7bitnn” .
$email_message . “nn”;
$data = chunk_split(base64_encode($data));
$email_message .= “–{$mime_boundary}n” .
“Content-Type: {$fileatt_type};n” .
” name=”{$fileatt_name}”n” .
“Content-Transfer-Encoding: base64nn” .
$data . “nn” .
“–{$mime_boundary}–n”;
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if($ok)
{
echo “<font face=verdana size=2>The Attach Email with File was successfully sent! TO Mr. $email_to</font>”;
}
else
{
die(“Sorry but the email could not be sent.Check plz offline or online servere. Please go back and try again! TO Mr. $email_to”);
}
$file = $uploadfile;
if (!unlink($file))
{
echo (“Error deleting $file”);
}
/*else
{
echo (“Deleted $file”);
}*/
}//if move upload file close
//attach mail sending close
}
}
else
{
echo “You should Enter the required fields”;
}
?>