HELP FORM CREATO IN PHP

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
37
Buongiorno, all'interno di un sito cliente le mail inviate col form contatti non arrivano, ho solo accesso tramite ftp e il form è creato in php (screen allegato) dove devo inserire la mail del destinatario in quanto non ci sono pannelli di configurazione ne CMS?

grazie
 

Allegati

  • Cattura.JPG
    Cattura.JPG
    235,3 KB · Visite: 436
Ultima modifica di un moderatore:
Ciao, il file php della pagina dove è inserito il form è scritto cosi:
PHP:
<?php include("_partials/_xsrf.php") ?>
<!doctype html>
    <html class="no-js" lang="it">
    <head>
        <?php include("_partials/_head.php") ?>
        <title>Bettega – Contatti</title>
        <meta name="description" content="Bettega realizza case in legno straordinarie. Contattaci per qualsiasi informazione.">
    </head>
    <body>
        <header class="c-masthead">
            <?php include("_partials/_header.php") ?>
            <div class="c-hero">
                <div class="c-hero__background rellax" data-rellax-speed="-4" style="background-image: url('assets/images/hero/interni.jpg');"></div>
            </div>
        </header>
        <div class="t-theme-primary">
            <div class="o-grid o-grid--bottom o-grid--half@ms o-bridge-vertical o-bridge-horizontal o-bridge-horizontal-3x@ls o-constrained">
                <div class="u-centered">
                    <img class="c-evil-logo" src="assets/images/logo_plain.svg" alt="">
                </div>
                <div class="u-centered¬ms">
                    <p class="c-evil-title">Bettega Legnami S.r.l.</p>
                    <ul class="o-item-list">
                        <li>Via Meatoli 20 - 38050 Imer (TN)</li>
                        <li>tel 0439 67286</li>
                        <li>fax 0439 725797</li>
                        <li>P.Iva 02371800224</li>
                        <li><a href="mailto:info@bettegalegnami.it">info@bettegalegnami.it</a></li>
                    </ul>
                </div>
            </div>
            <section class="c-box o-island o-island-triple@ms o-constrained">
                <?php include("_partials/_contacts.php") ?>
            </section>
        </div>
        <section class="o-bridge-vertical o-bridge-horizontal o-bridge-horizontal-3x@ms o-constrained u-centered">
            <h2 class="c-main-title">Dove siamo</h2>
            <a target="_blank" href="https://www.google.it/maps/place/Bettega+Atmosfera+Legno/@46.1490741,11.7938165,17z/data=!4m12!1m6!3m5!1s0x4778f6dbcb5b3b97:0xd0bba64b2e1d487c!2sBettega+Atmosfera+Legno!8m2!3d46.1490704!4d11.7960052!3m4!1s0x4778f6dbcb5b3b97:0xd0bba64b2e1d487c!8m2!3d46.1490704!4d11.7960052">
                <img src="assets/images/mappa.png" alt="">
            </a>
        </section>
        <?php include("_partials/_footer.php") ?>
    </body>
</html>




ED E PRESENTE UN FILE _XSRF COSI:

$name = '';
$email = '';
$city = '';
$message = '';
$errors = false;
$_SESSION['flash'] = ['errors' => [], 'success' => null];
// ready to validate
if (array_key_exists('name', $_POST)) {
$name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
if ($name === false) {
$_SESSION['flash']['errors'][] = 'name';
}
} else {
$_SESSION['flash']['errors'][] = 'name';
}
if (array_key_exists('email', $_POST)) {
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
if($email === false) {
$_SESSION['flash']['errors'][] = 'email';
}
} else {
$_SESSION['flash']['errors'][] = 'email';
}
if (array_key_exists('city', $_POST)) {
$city = filter_var($_POST['city'], FILTER_SANITIZE_STRING);
if ($city === false) {
$_SESSION['flash']['errors'][] = 'city';
}
} else {
$_SESSION['flash']['errors'][] = 'city';
}
if (array_key_exists('message', $_POST)) {
$message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
if ($message === false) {
$_SESSION['flash']['errors'][] = 'name';
}
} else {
$_SESSION['flash']['errors'][] = 'message';
}
if(!$errors) {
$transport = (new Swift_SmtpTransport(getenv('MAIL_DRIVER') . '.' .getenv('MAIL_HOST'), getenv('MAIL_PORT'), getenv('MAIL_SECURITY')))
->setUsername(getenv('MAIL_USERNAME'))
->setPassword(getenv('MAIL_PASSWORD'));
$mailer = new Swift_Mailer($transport);
$message = (new Swift_Message('Nuova Richiesta di Contatto'))
->setFrom([$email => $name])
->setTo([getenv('MAIL_TO') => getenv('MAIL_TO_NAME')])
->setBody($message);
$result = $mailer->send($message);
$_SESSION['flash'] = ['errors' => [], 'success' => 'Grazie per averci contattato!'];
// SEND ALL THE EMAILS
}
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
 
Ultima modifica di un moderatore:
Leggi il log o attiva il debug per vedere cosa dice.... probabile che non riesce a trovare il record MX del dns!
 
@marcozimol
Da regolamento del forum, come tutti noi sei tenuto ad usare il tag
code-gif.6007
o il tag
php-png.6009
per il PHP, quando posti del codice, oppure la funzione codice dalla barra degli strumenti
box-inserisci-2-png-jpg.6008

Inoltre ti prego di leggere attentamente il regolamento generale del forum e quello di sezione dove posti
Grazie
Per questa volta te lo sistemo io ma mi raccomando per il futuro
 
@marcozimol
Da regolamento del forum, come tutti noi sei tenuto ad usare il tag
code-gif.6007
o il tag
php-png.6009
per il PHP, quando posti del codice, oppure la funzione codice dalla barra degli strumenti
box-inserisci-2-png-jpg.6008

Inoltre ti prego di leggere attentamente il regolamento generale del forum e quello di sezione dove posti
Grazie
Per questa volta te lo sistemo io ma mi raccomando per il futuro

Ok grazie mille della dritta
 
Leggi il log o attiva il debug per vedere cosa dice.... probabile che non riesce a trovare il record MX del dns!
Scusami ma non sono pratico di questi procedimenti, dove dovrei agire per fare queste operazioni? cè un codice che devo inserire con l'indirizzo email da qualche parte?

Ho solo gli accessi FTP e nient'altro, non posso accedere alla mail o all'hosting

grazie
 
Qualcuno sa dirmi se nella parte finale va sositutito qualcosa per impostare la mail?

Codice:
    $_SESSION['csrf_token'] = base64_encode(openssl_random_pseudo_bytes(32));
}
// Check a POST is valid.
if (isset($_POST['csrf_token']) && $_POST['csrf_token'] === $_SESSION['csrf_token']) {

    $name = '';
    $email = '';
    $city = '';
    $message = '';

    $errors = false;
    $_SESSION['flash'] = ['errors' => [], 'success' => null];

    // ready to validate
    if (array_key_exists('name', $_POST)) {
        $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
        if ($name === false) {
            $_SESSION['flash']['errors'][] = 'name';
        }
    } else {
        $_SESSION['flash']['errors'][] = 'name';
    }

    if (array_key_exists('email', $_POST)) {
        $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
        $email = filter_var($email, FILTER_VALIDATE_EMAIL);
        if($email === false) {
            $_SESSION['flash']['errors'][] = 'email';
        }
    } else {
        $_SESSION['flash']['errors'][] = 'email';
    }

    if (array_key_exists('city', $_POST)) {
        $city = filter_var($_POST['city'], FILTER_SANITIZE_STRING);
        if ($city === false) {
            $_SESSION['flash']['errors'][] = 'city';
        }
    } else {
        $_SESSION['flash']['errors'][] = 'city';
    }

    if (array_key_exists('message', $_POST)) {
        $message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
        if ($message === false) {
            $_SESSION['flash']['errors'][] = 'name';
        }
    } else {
        $_SESSION['flash']['errors'][] = 'message';
    }

    if(!$errors) {

        $transport = (new Swift_SmtpTransport(getenv('MAIL_DRIVER') . '.' .getenv('MAIL_HOST'), getenv('MAIL_PORT'), getenv('MAIL_SECURITY')))
            ->setUsername(getenv('MAIL_USERNAME'))
            ->setPassword(getenv('MAIL_PASSWORD'));

        $mailer = new Swift_Mailer($transport);

        $message = (new Swift_Message('Nuova Richiesta di Contatto'))
            ->setFrom([$email => $name])
            ->setTo([getenv('MAIL_TO') => getenv('MAIL_TO_NAME')])
            ->setBody($message);

        $result = $mailer->send($message);


        $_SESSION['flash'] = ['errors' => [], 'success' => 'Grazie per averci contattato!'];
        // SEND ALL THE EMAILS

    }

    header('Location: ' . $_SERVER['HTTP_REFERER']);
 
Qualcuno sa dirmi se nella parte finale va sositutito qualcosa per impostare la mail?
Stai utilizzando symfony ?
Hai abilitato il log (si fa da codice con i framework e non da macchina)?
Hai visto cosa contiene la variabile result?
La conf dei parametri email è corretta?
Il server mail è corretto?
Il record MX è presente?

Che aiuto vuoi se non rispondi alle domande?
Da qui cosa vuoi che ti rispondano le persone?

Queste variabili sono settate correttamente?
PHP:
getenv('MAIL_DRIVER') . '.' .getenv('MAIL_HOST'), getenv('MAIL_PORT'), getenv('MAIL_SECURITY')

Non so cosa hai messo, potrebbe anche essere localhost:25 è in quel caso l'smtp non funziona....
 
Stai utilizzando symfony ?
Hai abilitato il log (si fa da codice con i framework e non da macchina)?
Hai visto cosa contiene la variabile result?
La conf dei parametri email è corretta?
Il server mail è corretto?
Il record MX è presente?

Che aiuto vuoi se non rispondi alle domande?
Da qui cosa vuoi che ti rispondano le persone?

Queste variabili sono settate correttamente?
PHP:
getenv('MAIL_DRIVER') . '.' .getenv('MAIL_HOST'), getenv('MAIL_PORT'), getenv('MAIL_SECURITY')

Non so cosa hai messo, potrebbe anche essere localhost:25 è in quel caso l'smtp non funziona....

Ciao, io ho accesso a questo sito tramite FTP e basta non ho accesso all amail ne all'hosting del sito, non è stato creato da me, il problema è che le mail non arrivano dal form contatti, la domanda è all'interno di questo codice e delle pagine che ho postato sopra nel primo messaggio è da inserire la mail del destinatario? in quanto non sono pratico del linguaggio php e non so dove agire all'interno della pagina per controllare se la mail è corretta (sempre che sia stata settata)

le variabili che hai indicato non sono settate sono così come le ho postate sopra

grazie per l'aiuto
 
Ciao, io ho accesso a questo sito tramite FTP e basta
Scusa le variabili dove vuoi settarle se non sul file che viene caricato in FTP?

il problema è che le mail non arrivano dal form contatti, la domanda è all'interno di questo codice e delle pagine che ho postato sopra nel primo messaggio è da inserire la mail del destinatario?
La risposta è: LE VARIABILI SONO SETTATE CORRETTAMENTE?

PHP:
// Create the Transport
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
  ->setUsername('your username')
  ->setPassword('your password')
  ;

/*
You could alternatively use a different transport such as Sendmail:

// Sendmail
$transport = new Swift_SendmailTransport('/usr/sbin/sendmail -bs');
*/

// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);

// Create a message
$message = (new Swift_Message('Wonderful Subject'))
  ->setFrom(['john@doe.com' => 'John Doe'])
  ->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
  ->setBody('Here is the message itself')
  ;

// Send the message
$result = $mailer->send($message);
Questo è il codice per swift_mail di symfony , stock....

Il problema è:
getenv('MAIL_DRIVER') . '.' .getenv('MAIL_HOST'), getenv('MAIL_PORT'), getenv('MAIL_SECURITY')
SONO SETTATE? se non dovessero essere settate lo script come fa a funzionare?
 
Scusa le variabili dove vuoi settarle se non sul file che viene caricato in FTP?


La risposta è: LE VARIABILI SONO SETTATE CORRETTAMENTE?

PHP:
// Create the Transport
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
  ->setUsername('your username')
  ->setPassword('your password')
  ;

/*
You could alternatively use a different transport such as Sendmail:

// Sendmail
$transport = new Swift_SendmailTransport('/usr/sbin/sendmail -bs');
*/

// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);

// Create a message
$message = (new Swift_Message('Wonderful Subject'))
  ->setFrom(['john@doe.com' => 'John Doe'])
  ->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
  ->setBody('Here is the message itself')
  ;

// Send the message
$result = $mailer->send($message);
Questo è il codice per swift_mail di symfony , stock....

Il problema è:

SONO SETTATE? se non dovessero essere settate lo script come fa a funzionare?

Ti ringrazio per la risposta, questi parametri non sono settati, cioè sono cosi come sono riportati:
quindi mi daresti conferma che chi ha realizzato il sito non ha impostato correttamente il form se li ha lasciati cosi?

getenv('MAIL_DRIVER') . '.' .getenv('MAIL_HOST'), getenv('MAIL_PORT'), getenv('MAIL_SECURITY')
 
Ti ringrazio per la risposta, questi parametri non sono settati, cioè sono cosi come sono riportati:
quindi mi daresti conferma che chi ha realizzato il sito non ha impostato correttamente il form se li ha lasciati cosi?
NO!
PHP:
getenv('MAIL_DRIVER')  //getenv — Gets the value of an environment variable
Non so che parametri sono settati sulla macchina.... forse dovresti fare qualche approfondimento in più
 
NO!
PHP:
getenv('MAIL_DRIVER')  //getenv — Gets the value of an environment variable
Non so che parametri sono settati sulla macchina.... forse dovresti fare qualche approfondimento in più

Quindi questo dovrebbero saperlo solamente i gestori del server dove è appoggiato il sito?
 

Discussioni simili