I can not use the PHPMAILER casse, because the hosting server does not accept, (Information from the server support itself)
I have this example, but the attached file always comes with an error. and I also can not write message in the body of the email.
$boundary = "XYZ-".md5(date("dmYis"))."-ZYX";
$path = $_FILES['fTxtArquivo']['tmp_name'];
$fileType = $_FILES['fTxtArquivo']['type'];
$fileName = $_FILES['fTxtArquivo']['name'];
// Pegando o conteúdo do arquivo
$fp = fopen( $path, "rb" ); // abre o arquivo enviado
$anexo = fread( $fp, filesize( $path ) ); // calcula o tamanho
$anexo = chunk_split(base64_encode( $anexo )); // codifica o anexo em base 64
fclose( $fp ); // fecha o arquivo
$headers = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-Type: multipart/mixed; ";
$headers .= "boundary=" . $boundary . PHP_EOL;
$headers .= "$boundary" . PHP_EOL;
$mensagem = "--$boundary" . PHP_EOL;
$mensagem .= "Content-Type: text/html; charset='utf-8'" . PHP_EOL;
$mensagem .= "Mensagem: teste"; // Adicione aqui sua mensagem
$mensagem .= "--$boundary" . PHP_EOL;
$mensagem .= "Content-Type: ". $fileType ."; name=\"". $fileName . "\"" . PHP_EOL;
$mensagem .= "Content-Transfer-Encoding: base64" . PHP_EOL;
$mensagem .= "Content-Disposition: attachment; filename=\"". $fileName . "\"" . PHP_EOL;
$mensagem .= "$anexo" . PHP_EOL;
$mensagem .= "--$boundary" . PHP_EOL;
$envio = mail("[email protected]", $assunto, $mensagem, $headers);
Someone has a simple example, to send email with attachment!