Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29745

mail functon don't read variable from form

$
0
0

i don't understand why my function don't put the content of the variable inside the email.

This is the code of the form

<form name="richiestaMozioniComunali" action="./mail_function/mozioni_comunali_mail.php"
                        novalidate="novalidate">
                        <div class="row">
                            <div class="col-md-12">



                                <div class="form-group">
                                    <input class="form-control" name="mozione" id="mozione" type="text" placeholder="Mozione"
                                        required="required"
                                        data-validation-required-message="Inserisci qualcosa in questo campo">
                                    <p class="help-block text-danger"></p>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" id="nome" name="nome" type="text" placeholder="Nome"
                                        data-validation-required-message="Inserisci qualcosa in questo campo">
                                    <p class="help-block text-danger"></p>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" id="cognome" name="cognome" type="text" placeholder="Cognome"
                                        data-validation-required-message="Inserisci qualcosa in questo campo">
                                    <p class="help-block text-danger"></p>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" id="citta" name="citta" type="text" placeholder="Città"
                                        data-validation-required-message="Inserisci qualcosa in questo campo">
                                    <p class="help-block text-danger"></p>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" id="ruolo_politico" name="ruolo_politico" type="text"
                                        placeholder="Ruolo politico"
                                        data-validation-required-message="Inserisci qualcosa in questo campo">
                                    <p class="help-block text-danger"></p>
                                </div>
                                <div class="form-group">
                                    <input class="form-control" id="testo_richiesta" name="testo_richiesta" type="text" placeholder="Testo"
                                        data-validation-required-message="Inserisci qualcosa in questo campo">
                                    <p class="help-block text-danger"></p>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="col-lg-12 text-center">
                                <div id="success"></div>
                                <button id="sendMessageButton" class="btn btn-primary btn-xl text-uppercase"
                                    type="submit">Send Message</button>
                            </div>
                        </div>
                    </form>

And the mail function that is in another file:

<?php

    $_POST["mozione"] = $mozione;
    $_POST["nome"] = $nome;
    $_POST["cognome"] = $cognome;
    $_POST["citta"] = $citta;
    $_POST["ruolo_politico"] = $ruolo_politico;
    $_POST["testo_richiesta"] = $testo_richiesta;

    // Genera un boundary
    $mail_boundary = "=_NextPart_" . md5(uniqid(time()));

    //inoltreap.territori@gmail.com
    $to = "inoltreap.territori@gmail.com";
    $subject = "Modulo selezione email - inoltreAP website";
    $sender = "postmaster@inoltreap.it";

    $headers = "From: $sender\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/alternative;\n\tboundary=\"$mail_boundary\"\n";
    $headers .= "X-Mailer: PHP " . phpversion();

    // Corpi del messaggio nei due formati testo e HTML
    $text_msg = "messaggio in formato testo";
    $html_msg = "<b>messaggio</b> in formato <p><a href='http://www.aruba.it'>html</a><br><img src=\"http://hosting.aruba.it/image_top/top_01.gif\" border=\"0\"></p>";

    $msg .= "\n--$mail_boundary\n";
    $msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
    $msg .= "Content-Transfer-Encoding: 8bit\n\n";
    $msg .= "Email inviata dal form <b>MODULO SEGNALAZIONI<b><br><b>Mozione<b>"; // aggiungi il messaggio in formato HTML
    $msg .= $mozione;
    $msg .= "<br><b>Nome: </b>";
    $msg .= $nome;
    $msg .= "<br><b>Cognome: </b>";
    $msg .= $cognome;
    $msg .= "<br><b>Citta: </b>";
    $msg .= $citta;
    $msg .= "<br><b>Via: </b>";
    $msg .= $via;
    $msg .= "<br><b>Testo richiesta:</b>";
    $msg .= $testo_richiesta;

    // Boundary di terminazione multipart/alternative
    $msg .= "\n--$mail_boundary--\n";

    // Imposta il Return-Path (funziona solo su hosting Windows)
    ini_set("sendmail_from", $sender);

    // Invia il messaggio, il quinto parametro "-f$sender" imposta il Return-Path su hosting Linux
    if (mail($to, $subject, $msg, $headers, "-f$sender"))
    {
        echo "Mail inviata correttamente !";
    }
    else
    {
        echo "<br><br>Recapito e-Mail fallito!";
    }
?>

I already done another mail function that works, but it was in the same file and i think that i forgot something. Also i tried to use $_REQUEST and $_GET instead of $_POST but it didn't work. When i receive the email i have the text without the contents of the variabile with '$'


Viewing all articles
Browse latest Browse all 29745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>