$fullname = trim($_POST['fullname']);
$email = trim($_POST['email']);
$subject = trim($_POST['subject']);
$msg = trim($_POST['message']);
$content = $fullname."\n\n".$email."\n\n".$msg;
echo '
'.'Thank you for your interests!'.'
';
$data = substr($_POST['img'], strpos($_POST['img'], ",") + 1);
$decodedData = base64_decode($data);
$origname = mktime();
$origname .= '.png';
$fp = fopen($origname, 'wb');
fwrite($fp, $decodedData);
fclose($fp);
//$message must contain all text post data concatenated and formatted
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$headers = "MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
$type = 'image/png';
$name = 'yourpic.png';
$size = filesize($origname);
$file = fopen($origname,'rb');
$data = fread($file,filesize($origname));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
// here's our closing mime boundary that indicates the last of the message
$message.="--{$mime_boundary}\n";
$message .= "--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$content . "\n\n";
$message.="--{$mime_boundary}--\n";
// now we just send the message
$to = 'kdsecor@gmail.com';
//$sbj = $subject;
//$msg = $message;
//$headers = 'From: kimjaej@gmail.com' . "\r\n" .
mail($to, 'Your pic', $message, $headers);
?>