1
I use a very simple form of sending data to e-mail, I included an upload button... How to make a simple schedule so that this file is sent in the e-mail as an attachment?
<div class="contato">
<div class="container">
<h2>Inscreva-se já!</h2>
<form action="email-2.php" method="post">
<input type="text" name="nome" size="" placeholder="Nome Completo"><br>
<input type="text" name="endereco" size="" placeholder="Endereço"><br>
<input type="text" name="cpf" size="" placeholder="CPF"><br>
<input type="text" name="rg" size="" placeholder="RG"><br>
<input type="text" name="fone" size="" placeholder="Telefone"><br>
<input type="text" name="email" size="" placeholder="E-mail"><br>
<input type="file" />
<textarea name="mensagem" cols="65" rows="8" placeholder="Escreva aqui sua mensagem"></textarea><br>
<div class="botao-contato">
<input class="botao" type="submit" value="Enviar"><br>
</div>
</form>
</div>
<?php
$nome = $_POST['nome'];
$endereco = $_POST['endereco'];
$cpf = $_POST['cpf'];
$rg = $_POST['rg'];
$email = $_POST['email'];
$fone = $_POST['fone'];
$msg = $_POST['mensagem'];
$destino = "[email protected]";
$assunto = "Cadastro Via Site";
$headers = "From: ". $nome;
$headers .= "\r\n" . 'Cc: [email protected]' . "\r\n";
$corpoemail = 'Contato Via site
Nome: ' .$nome.'
Endereço: ' .$endereco.'
CPF: ' .$cpf.'
RG: ' .$rg.'
Email: ' .$email.'
Fone: ' .$fone.'
Mensagem: '.$msg.' ';
if(mail($destino, $assunto, $corpoemail, $headers)){
echo "<script>alert('Cadastro enviado com
sucesso!');document.location='index.php';</script>";
} else{
echo "<script>alert('Erro ao enviar, tente diretamente pelo
[email protected]');</script>";
}
?>
Use php Mailer: https://github.com/PHPMailer/PHPMailer Sample attachment code using Addattachment https://code.google.com/archive/apache-extras.org/p/phpmailer/wikis/AdvancedMail.wiki
– Samuel Ives