0
I have a problem in this code, because when sending is done sending the information I receive the return = 1, however the attachment is not sent someone can help me?
SENDING.PHP
$arquivoreal = $_FILES['arquivo'];
$Nome = $_POST['Nome'];
$CPF = $_POST['CPF'];
//Configurações do email, ajustar conforme necessidade
//====================================================
$email_destinatario ="[email protected]"; // pode ser qualquer email que receberá as mensagens
$email_reply = "Supervisão";
$email_assunto = "Curriculo"; // Este será o assunto da mensagem
//====================================================
//Monta o Corpo da Mensagem
//====================================================
$email_conteudo = "<h1>Envio de Curriculo [SITE]</h1>
<p>$Nome CPF: $CPF gostaria de fazer parte do nosso quadro de funcionarios, por isso enviou o curriculo pelo site <br>
(Curriculo em anexo)</p>";
//====================================================
//Enviando o email
//====================================================
// EnviaEmailCorandini(assunto,msg corpo do email,email,Nome Destinatario,Arquivo em anexo);
$retorno = EnviaEmailCorandini($email_assunto,$email_conteudo,$email_destinatario,$email_reply,$arquivoreal);
if($retorno == 1){
header("Location:index.php");
}else{
echo "Falha ao enviar o email";
}
}
}
Phpmailer/index.php
require 'PHPMailerAutoload.php';
function EnviaEmail($assunto,$msg,$EmailDestino,$NomeDestino,$NomeArquivo){
$mail = new PHPMailer();
$mail->setLanguage('pt');
$mail->isSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $user;
$mail->Password = $password;
$mail->Port = $port;
$mail->SMTPSecure = $secure;
$mail->From = $from;
$mail->FromName = $fromName;
$mail->addReplyTo($from,$fromName);
$mail->addAddress($EmailDestino,$NomeDestino);
$mail->isHTML(true);
$mail->CharSet = 'utf-8';
$mail->WordWrap = 70;
$mail->Subject = $assunto;
$mail->Body = $msg;
$mail->AddAttachment($NomeArquivo);
$send = $mail->Send();
if($send)
return 1;
else
return 0;
}
It is returning one because in fact the email has been sent. From an echo in this $filename and try to access the file through the browser. Remember that for phpmailer to attach the absolute file path is required.
– Bruno Folle
The issue is confusing, you use the Enviaemailcorandini class but you paste the code from the Enviaemail class. There you have the last parameter $Filename but it is sent an Array $arquivoreal = $_FILES['file'], if you want only the name of the file would be $_FILES['file']['tmp_name'], had not searched the manual: http://php.net/manualpt_BR/features.file-uploadpost-method.php
– Gustavo Jantsch