Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. una funzione che non parte :(

una funzione che non parte :(

Pianificato Fissato Bloccato Spostato Coding
3 Post 2 Autori 556 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • D
    D
    dariomarco
    scritto su ultima modifica di
    User Attivo 0
    #1
    una funzione che non parte :(

    Salve a tutti,
    ho trovato uno script che verifica l'esistenza di un indirizzo email, ma copio e incollo il codice nella mia pagina e chiamo la funzione, ma non funziona nulla.
    il codice si trova su questa pagina:
    w w w .barattalo.it/2009/12/27/...mail-with-smtp/

    la funzione la chiamo con una semplice chiamata del tipo:

    validateEmailSmtp("[email protected]")

    ma mi appare la pagina bianca.

    Dove sbaglio?
    Grazie, ciao.

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • R
      R
      rcayla
      scritto su ultima modifica di
      User 0
      #2

      Se non posti il codice è difficile aiutarti...

      EDIT: Ho visto ora il codice alla pagina che hai linkato.
      Hai provato a mettere $debug = true?

      1 Risposta Ultima Risposta
      Miglior risposta 0
      0
      • D
        D
        dariomarco
        scritto su ultima modifica di
        User Attivo 0
        #3

        Grazie per la tua risposta RCayla, magari se potresti provarlo anche tu, te ne sarei grato.

        function validateEmailSmtp($email, $probe_address="", $debug=false) {
            # --------------------------------
            # function to validate email address
            # through a smtp connection with the
            # mail server.
            # by Giulio Pons
            # barattalo.it scusa ho dovuto tagliare ma si capisce
            # --------------------------------
            $output = "";
            # --------------------------------
            # Check syntax with regular expression
            # --------------------------------
            if (!$probe_address) $probe_address = $_SERVER["SERVER_ADMIN"];
            if (preg_match('/^([a-zA-Z0-9\._\+-]+)\@((\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,7}|[0-9]{1,3})(\]?))$/', $email, $matches)) {
                $user = $matches[1];
                $domain = $matches[2];
                # --------------------------------
                # Check availability of DNS MX records
                # --------------------------------
                if (function_exists('checkdnsrr')) {
                    # --------------------------------
                    # Construct array of available mailservers
                    # --------------------------------
                    if(getmxrr($domain, $mxhosts, $mxweight)) {
                        for($i=0;$i<count($mxhosts);$i++){
                            $mxs[$mxhosts[$i]] = $mxweight[$i];
                        }
                        asort($mxs);
                        $mailers = array_keys($mxs);
                    } elseif(checkdnsrr($domain, 'A')) {
                        $mailers[0] = gethostbyname($domain);
                    } else {
                        $mailers=array();
                    }
                    $total = count($mailers);
                    # --------------------------------
                    # Query each mailserver
                    # --------------------------------
                    if($total > 0) {
                        # --------------------------------
                        # Check if mailers accept mail
                        # --------------------------------
                        for($n=0; $n < $total; $n++) {
                            # --------------------------------
                            # Check if socket can be opened
                            # --------------------------------
                            if($debug) { $output .= "Checking server $mailers[$n]...\n";}
                            $connect_timeout = 2;
                            $errno = 0;
                            $errstr = 0;
                            # --------------------------------
                            # controllo probe address
                            # --------------------------------
                            if (preg_match('/^([a-zA-Z0-9\._\+-]+)\@((\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,7}|[0-9]{1,3})(\]?))$/', $probe_address,$fakematches)) {
                                $probe_domain = str_replace("@","",strstr($probe_address, '@'));
        
                                # --------------------------------
                                # Try to open up socket
                                # --------------------------------
                                if($sock = @fsockopen($mailers[$n], 25, $errno , $errstr, $connect_timeout)) {
                                    $response = fgets($sock);
                                    if($debug) {$output .= "Opening up socket to $mailers[$n]... Success!\n";}
                                    stream_set_timeout($sock, 5);
                                    $meta = stream_get_meta_data($sock);
                                    if($debug) { $output .= "$mailers[$n] replied: $response\n";}
                                    # --------------------------------
                                    # Be sure to set this correctly!
                                    # --------------------------------
                                    $cmds = array(
                                        "HELO $probe_domain",
                                        "MAIL FROM: <$probe_address>",
                                        "RCPT TO: <$email>",
                                        "QUIT",
                                    );
                                    # --------------------------------
                                    # Hard error on connect -> break out
                                    # --------------------------------
                                    if(!$meta['timed_out'] && !preg_match('/^2\d\d[ -]/', $response)) {
                                        $codice = trim(substr(trim($response),0,3));
                                        if ($codice=="421") {
                                            //421 #4.4.5 Too many connections to this host.
                                            $error = $response;
                                            break;
                                        } else {
                                            if($response=="" || $codice=="") {
                                                //c'è stato un errore ma la situazione è poco chiara
                                                $codice = "0";
                                            }
                                            $error = "Error: $mailers[$n] said: $response\n";
                                            break;
                                        }
                                        break;
                                    }
                                    foreach($cmds as $cmd) {
                                        $before = microtime(true);
                                        fputs($sock, "$cmd\r\n");
                                        $response = fgets($sock, 4096);
                                        $t = 1000*(microtime(true)-$before);
                                        if($debug) {$output .= "$cmd\n$response" . "(" . sprintf('%.2f', $t) . " ms)\n";}
                                        if(!$meta['timed_out'] && preg_match('/^5\d\d[ -]/', $response)) {
                                            $codice = trim(substr(trim($response),0,3));
                                            if ($codice<>"552") {
                                                $error = "Unverified address: $mailers[$n] said: $response";
                                                break 2;
                                            } else {
                                                $error = $response;
                                                break 2;
                                            }
                                            # --------------------------------
                                            // il 554 e il 552 sono quota
                                            // 554 Recipient address rejected: mailbox overquota
                                            // 552 RCPT TO: Mailbox disk quota exceeded
                                            # --------------------------------
                                        }
                                    }
                                    fclose($sock);
                                    if($debug) { $output .= "Succesful communication with $mailers[$n], no hard errors, assuming OK\n";}
                                    break;
                                } elseif($n == $total-1) {
                                    $error = "None of the mailservers listed for $domain could be contacted";
                                    $codice = "0";
                                }
                            } else {
                                $error = "Il probe_address non è una mail valida.";
                            }
                        }
                    } elseif($total <= 0) {
                        $error = "No usable DNS records found for domain '$domain'";
                    }
                }
            } else {
                $error = 'Address syntax not correct';
            }
            if($debug) {
                print nl2br(htmlentities($output));
            }
            if(!isset($codice)) {$codice="n.a.";}
            if(isset($error)) return array($error,$codice); else return true;
        }
        

        1 Risposta Ultima Risposta
        Miglior risposta 0
        0

        Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

        Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

        Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

        Registrati Accedi
        Rispondi
        • Risposta alla discussione
        Effettua l'accesso per rispondere
        • Da Vecchi a Nuovi
        • Da Nuovi a Vecchi
        • Più Voti


        • Accedi

        • Non hai un account? Registrati

        • Accedi o registrati per effettuare la ricerca.
        • Primo post
          Ultimo post
        Home Accedi Registrati
        Menu
        • CATEGORIES
        • La Community Connect.gt
        • Presentati alla Community
        • News Ufficiali da Connect.gt
        • Internet News
        • A Scuola Di
        • Digital Marketing
        • Intelligenza Artificiale
        • SEO & GEO
        • Web Marketing e Content
        • Google Analytics e Web Analytics
        • Google Ads & Advertising
        • YouTube
        • TikTok, Instagram e altri Social
        • Google Adsense, Affiliazioni e Guadagno
        • E-Commerce
        • Coding e Sistemistica
        • Help Center: consigli per il tuo progetto
        • Hosting e Cloud
        • Coding
        • CMS & Piattaforme Self-Hosted
        • Annunci e Collaborazioni
        • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
        • Collaborazioni WEB e Lavoro: offro e cerco
        • Impresa, Fisco e Leggi
        • Consulenza Legale e Professioni Web
        • Consulenza Fiscale, Imprese, Startup e P.Iva
        • Gli Off Topic
        • PC, Smartphone e altri Hardware
        • Tutti i Software
        • GT Fetish Cafè
        • Discussioni
        • Non letti 0
        • Recenti
        • Hashtag
        • Popolare
        • Utenti
        • Privacy
        • Termini e condizioni
        • © 2026 Search On Media Group S.r.l.