Once again i desperately need your help.
Ok here comes the problem. I was asked to create a mail form with attatchment.
In order to do that i created two files, the contact.html and the post.php.
Also i created a Folder into the server called ForMail, in order to store the attatchments, before they will be sent.
(I am testing these two file by sending mails to myself - my mail address is hosted in yahoo ).
Now when i test the files, i am receiving the mail, but i can' t see neither the message or the attatchment.
I tried to find a solution but i failed.
Please if anyone can help me just post the write code , because i have to deliver these files today
I am giving you below the code of the two files
Contact.html
Code: Select all
<table cellpadding="0" cellspacing="5">
<form action="post.php" method="post" onsubmit="return check_form(this)" enctype="multipart/form-data" >
<tr>
<td align="right"><font face="Verdana" size="-1">???: </font></td>
<td align="left"><input type="text" name="name" size="50" style="background-color:#9393FF" /></td>
</tr>
<tr>
<td align="right"><font face="Verdana" size="-1">Email: </font></td>
<td align="left"><input type="text" name="email" size="50" style="background-color:#9393FF" id="email" /></td>
</tr>
<tr>
<td align="right"><font face="Verdana" size="-1">????: </font></td>
<td align="left"><input type="text" name="subject" size="50" style="background-color:#9393FF" /> </td>
</tr>
<tr>
<td align="right" valign="top"><font face="Verdana" size="-1">??????: </font></td>
<td align="left">
<textarea name="message" rows="18" cols="60" style="background-color:#9393FF" ></textarea><br />
</td>
</tr>
<tr>
<td align="right" valign="top"><font face="Verdana" size="-1">??????????????: </font></td>
<td align="left"><input type="file" name="attachment" style="background-color:#9393FF" /> <br />
<input type="submit" value="????????" /> <br />
</td>
</tr>
</form>
</table>
Post.php
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>post</title>
</head>
<body>
<?php
$to = "kostasps2001g@yahoo.gr";
$name = $_REQUEST['name'];
$subject = $_REQUEST['subject'];
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
//$attachment = $_FILES['attachment'];
$target_path = "ForMail/" . $_FILES['attachment']['name'];
echo $target_path . "<br>";
if(move_uploaded_file($_FILES['attachment']['tmp_name'], $target_path)){
echo "The file ". $_FILES['attachment']['name']. " has been uploaded". "<br>";
}
else{
echo "There was an error uploading the file, please try again!". "<br>";
}
// Until here it works just fine
$file = file_get_contents($target_path);
$bound_text = "jimmyP123";
$bound = "--".$bound_text."\r\n";
$bound_last = "--".$bound_text."--\r\n";
$Myheaders = "From:".$name." <".$email.">";
$Myheaders .= "MIME-Version: 1.0\r\n"."Content-Type: multipart/mixed; boundary=\"$bound_text\"";
$Mymessage .= "If you can see this MIME than your client doesn't accept MIME types!\r\n".$bound;
$Mymessage .= "Content-Type: text/html; charset=\"utf-8\"\r\n"."Content-Transfer-Encoding: 7bit\r\n\r\n".$bound;
$Mymessage .= $message;
$Mymessage .= "Content-Type: image/jpg; name=\"attached.jpg\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-disposition: attachment; file=\"attached.jpg\"\r\n" . "\r\n"
.chunk_split(base64_encode($file)).$bound_last;
if(mail($to, $subject, $message, $Myheaders))
{
echo 'MAIL SENT';
}
else
{
echo 'MAIL FAILED';
?>
<br />
<a href="http://www.kostasps.gr/Dokanexitilo/contact.html">?????????</a>
</body>
</html>