Jump to content


Dico

Member Since 28/01/2008
Offline Last Active 10/07/2017, 21:34
-----

Topics I've Started

Enviar Email Com Anexo: File Chega Em Branco

09/05/2009, 17:34

pessoal o problema é o seguinte:

uso esse script para enviar email com anexo diretamente pro meu email,
a mensagem, subject, o email da pessoa e o anexo chegam direitinho, mas o arquivo em anexo sempre chega em branco, alguem poderia dar uma ajuda? abraços...



<?php
$aposenviar='http://www.paginaquevemdepois.com/ok.html';

if ($filea)
{
function mail_attachment ($to, $nome, $nome1, $subject, $message, $attachment){
$fileatt = $attachment; // Path to the file
$fileatt_type = "txt/doc"; // File Type
$start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
$fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment

$email_from = $nome; // Who the email is from
$emailcli = $nome1; // Who the email is from
$subject = "pedido";
$email_subject = $subject; // The Subject of the email
$email_txt = $message; // Message that the email has in it

$email_to = $to; // Who the email is to

$headers = "From: ".$nome;


$msg_txt=" <table><tr><td>$nome</td></tr> <tr><td>$nome1</td></tr> <tr><td>$subject</td></tr><tr><td> $message</td></tr></table>";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_txt .= $msg_txt;
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_txt . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\y\y" .
"--{$mime_boundary}--\n";

$ok = mail($email_to, $email_subject, $email_message, $headers, $attachment);

if($ok)
{
echo "&lt;script>window.location='$aposenviar'</script>";

}
else
{
die("Sorry but the email could not be sent. Please go back and try again!");
}
}


mail_attachment("meuemail@hotmail.com", "$nome", "$nome1", "$subject", "$message", ("temp/".$_FILES["filea"]["name"]));
}
?>

IPB Skin By Virteq