Send attachments by for forms

Asked

Viewed 43 times

0

People need to send attachments per form with PHP, without using plugins and things like, how do I do this ?

My code currently:

<?php
    if (isset($_POST[nome])){
    $nome =   $_POST[nome];
    $email =  $_POST[email];
    $recado = $_POST[recado];
    $tipo = $_POST[tipo];
    $assunto = "[DENÚNCIA] - " . $tipo;

        $send = ("[email protected]"); //Coloque seu E-mail aqui.

        $data = date("d/m/y");     
        $hora = date("H:i:s");
        $ip = $_SERVER[REMOTE_ADDR];

        $headers .= "From: $send\r\n"; 
                                //para o envio em formato HTML
                                $headers = "MIME-Version: 1.0\r\n";
                                $headers .= "Content-type: text/html;
                                charset=iso-8859-1\r\n";

                                $corpo =("

                                            <b>De:</b> $_POST[nome]; <br/>
                                            <b>E-mail:</b> $email<br/>
                                            <b>Assunto:</b> $assunto<br/>
                                            <b>Para:</b> $send<br/>
                                            <b>Tipo:</b> $tipo<br/>
                                                <hr/><br/>
                                            <b>Recado:</b> <br/> 
                                            $recado
                                            <br/>
                                                <hr/>
                                            <br/>

                                            <b>Data:</b> $data <br/>
                                            <b>Hora:</b> $hora  <br/>
                                            <b>IP:</b>  $ip         <br/>

                                            ");

                                    mail($send, $assunto, $corpo, $headers); 

                                echo "<script type=\"text/javascript\"> alert('Obrigado $nome, Seu Recado Foi Enviado Com sucesso!!!') </script>";


    } else{


    }

  ?>
  • Easier to do with phpmailer https://github.com/PHPMailer/PHPMailer

  • but the problem is I can’t use it :/

  • You have a full answer here > https://answall.com/questions/11417/enviar-email-com-anexos-em-php

  • I don’t know if that’s what you need.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.