Mam takie coś...
[php:1:fe1658af62]
<?
$phpself = $_SERVER['PHP_SELF'];
function testMail($mail){
if(eregi("^[_.0-9a-z-]+@([0-9a-z]+.)+[a-z]{2,4}$",$mail)){
return 1;
} else {
echo "Niepoprawny E-mail!";
return 0;
}
}
function fileDecode($file)
{
if (is_readable($file)){
$fd = fopen($file, "r");
$plik = fread($fd, filesize($file));
$encoded = chunk_split(base64_encode($plik));
fclose($fd);
}
return $encoded;
}
function newMessageForm($to, $cc, $subject, $message)
{
echo "<form method=post action=$phpself?show=send enctype=multipart/form-data>Do: <input type=text name=to value=".$to."><br>Dw: <input type=text name=cc value=".$cc."><br>Temat: <input type=text name=subject value=".$subject."><br>Wiadomo¶ć: <textarea rows=6 cols=30 name=message>$message</textarea><br>Załącznik: <input type=file name=filename><br><br><select name=type><option value=text>TEXT</option><option value=html>HTML</option></select><br><br><input type=submit value=Wy¶lij></form>";
}
function sendMessage($to, $cc, $subject, $message, $type, $mailbox, $filename)
{
if(!empty($filename)){
if($subject && $message && testMail($to)){
$boundary = "-->===_54654747_===<---->>4255==_";
$headers = "MIME-Version: 1.0rn";
$headers .= "From: $mailbox <$mailbox>rn";
$headers .= "Cc: ".$cc."";
$headers .= "X-Mailer: php/".phpversion()."rn";
$headers .= "Content-type: multipart/mixed; ";
$headers .= "boundary="$boundary"n";
$headers .= "Content-transfer-encoding: 7BITn";
$headers .= "X-attachments: $filename_name;nn";
$message = "--" . $boundary . "n";
$message .= "Content-Type: text/plain; charset="us-ascii"nn";
$message .= $message . "n";
$message .= "--" . $boundary . "n";
$message .= "Content-type: " . $filename_type . "; name="$filename_name";n";
$message .= "Content-Transfer-Encoding: base64n";
$message .= "Content-disposition: attachment; filename= "$filename_name"nn";
$message .= fileDecode($filename) . "n";
$message .= "--" . $boundary . "-- n";
mail($to, $subject, $message, $headers);
echo "Wiadomość razem z załącznikiem została wysłana!";
} else {
echo "Należy podać wszystkie dane!";
}
} else {
if($type==html){
if($subject && $message && testMail($to)){
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $mailbox <$mailbox>rn";
$headers .= "Cc: ".$cc."";
$message = "<html><head><title>$subject</title></head><body>$message</body></html>";
mail($to, $subject, $message, $headers);
echo "Wiadomo¶ć w formacie HTML została wysłana";
} else {
echo "Należy podać wszystkie dane!";
}
} else {
if($subject && $message && testMail($to)){
$headers = "From: $mailbox <$mailbox>rn";
$headers .= "X-Mailer: php/".phpversion()."rn";
$headers .= "Content-Type: text/plain; charset=ISO-8859-2rn";
$headers .= "Content-Transfer-Encoding: 8bitrn";
$headers .= "Status: 0rn";
mail($to, $subject, $message, $headers);
echo "Wiadomo¶ć w formacie tekstowym została wysłana";
} else {
echo "Należy podać wszystkie dane";
}
}
}
}
?>
[/php:1:fe1658af62]
I kto mi powie dlaczego nie wysyła E-maili z załącznikami?