Ir para conteúdo
Fórum Script Brasil

faiscas

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que faiscas postou

  1. Boas. Estou com uma duvida. Estou a programar uma função em PHP para o envio de emails a partir do site. No entanto, estou com alguns problemas no "encode". Isto porque a mensagem se incluir caracteres especiais vem com um formato esquesito. Exemplo: "Acção" --> "Acção" (aqui aparece direito, mas no email aparece diferente, com um formato muito esquesito) Vou inserir aqui o codigo que inseri no mail.php para verem <?php // Read POST request params into global vars $to = $_POST['to']; $from = $_POST['from']; $subject = $_POST['subject']; $message = $_POST['message']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $message = "This is a multi-part message in MIME format.\r\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=iso-8859-2\r\n" . "Content-Transfer-Encoding: 8bit\r\nX" . $message . imap_8bit($message); // Base64 encode the file data $data = chunk_split(utf8_encode($data)); // Add file attachment to the message $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 . "\n\n" . "--{$mime_boundary}--\n"; } // Send the message $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p></p>"; echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL= emailsucesso.php'>"; } else { echo "<p>Envio falhou. Tente novamente.</p>"; echo "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL= emailfalhado.php'>"; } ?> Obrigado, Cumps PS: Como é a primeira vez que faço isto, não sei se está na secção correcta, nem se é assim que se coloca uma dúvida. Se estiver mal digam que eu mudo.
×
×
  • Criar Novo...