HELP FORM CREATO IN PHP

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
36
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: 381
Ultima modifica di un moderatore:

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
36
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:[email protected]">[email protected]</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:

macus_adi

Utente Attivo
5 Dic 2017
1.343
91
48
IT/SW
Leggi il log o attiva il debug per vedere cosa dice.... probabile che non riesce a trovare il record MX del dns!
 

Max 1

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
29 Feb 2012
4.449
338
83
@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

Nuovo Utente
29 Mag 2017
10
0
1
36
@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
 

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
36
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
 

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
36
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']);
 

macus_adi

Utente Attivo
5 Dic 2017
1.343
91
48
IT/SW
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....
 

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
36
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
 

macus_adi

Utente Attivo
5 Dic 2017
1.343
91
48
IT/SW
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(['[email protected]' => 'John Doe'])
  ->setTo(['[email protected]', '[email protected]' => '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?
 

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
36
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(['[email protected]' => 'John Doe'])
  ->setTo(['[email protected]', '[email protected]' => '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')
 

macus_adi

Utente Attivo
5 Dic 2017
1.343
91
48
IT/SW
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ù
 

marcozimol

Nuovo Utente
29 Mag 2017
10
0
1
36
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?
 

macus_adi

Utente Attivo
5 Dic 2017
1.343
91
48
IT/SW
Scusa @marcozimol , ma non fai prima a scrivere i parametri del server mail di test per vedere se funziona?

Cmq il programmatore dovrebbe darti supporto...
 
Discussioni simili
Autore Titolo Forum Risposte Data
D inserire datepicker in un form - help HTML e CSS 4
F [HELP] Adattare al form Visual Basic 0
A Form con più submit help! Javascript 1
P Help per form php PHP 4
J help - form php PHP 9
W help form contatti Help!!!! PHP 0
D Help form mail Supporto Mr.Webmaster 1
Z [Help] inserimento emoticons in form Javascript 2
S Help per reset campo in un form Javascript 3
M Help for Linux Bash Programmazione 1
E Help Sql somma orari PHP 32
P Passare i risultati di un foreach in un modal. Help! PHP 2
J help me C/C++ 1
K Help: problema con uno script di booking in php! PHP 0
Q HELP ME PLEASE!‼️‼️ E-Commerce 1
L difficoltà con Xampp. printing php mancante...help Web Server 6
K [PHP] Help me a problem... Pleases PHP 1
S Problemi con modulo upload video php (help!) PHP 0
M Help - consultare (ed esportare) dati da un DB pubblico mySql PHP 2
S [PHP] help me!! PHP 2
F Cerco contatto tipo help-desk Offerte e Richieste di Lavoro e/o Collaborazione 2
F Help-PDO copiare Database MySQL PHP 3
Andrea1981 [WordPress] [HTML] Help modifica credits nel footer.Tema Customizr. WordPress 5
simgia [Javascript] Google maps help! Javascript 1
S [WordPress] Footer php - il background riempie tutta la pagina - help WordPress 1
A funzioni asincrone e callback...help! Ajax 10
F Help array da javascript a php Javascript 2
M [PHP] Help: controllo valori inseriti in un campo PHP 1
P Help con js/php PHP 6
N Sistema di Help di Delphi 7 non funziona su Win10 Windows e Software 0
silvia88 ***Help*** - Anteprima immagine photoshop diversa da file Photoshop 3
A HELP: vedo il sito posizionato in serp solo con i tool di posizionamento!!! SEO e Posizionamento 3
T [PHP] Calcolo anzianità soggetti [era: Help me :( Esercizio per me impossibile] PHP 9
trattorino Creare codice php help PHP 26
CoyotesSon [PHP] Help! Creazione di una finestra PHP 5
V help java Java 2
L help me Presentati al Forum 0
L N00b need help Webdesign e Grafica 2
I Help - Problema installazione tema di themeforest WordPress 1
claudiav ciao!! help.. Presentati al Forum 0
Z Invio mail da telecamere HIKVision - HELP!!! IP Cam e Videosorveglianza 0
M - WordPress - Sito Annunci HELP ME!!!! :crying: WordPress 2
L Hosting, help HTML e CSS 2
M HoneyPot su macchina virtuale HELP ME PLEASE!!! Reti LAN e Wireless 0
F Help con leaseweb Hosting 2
M DropDownList HELP ASP.NET 8
E [Javascript] help me !!! array da php a java Javascript 9
N Query lenta, help ! MySQL 0
P Help! modifica script Javascript 11
R cookies policy - help Leggi, Normative e Fisco 21

Discussioni simili