Visualizzazione dei risultati da 1 a 10 su 11

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2011
    Messaggi
    192
    codice:
    /* Namespace alias. */
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;
    
    /* Include the Composer generated autoload.php file. */
    require 'C:\xampp\composer\vendor\autoload.php';
    
    /* If you installed PHPMailer without Composer do this instead: */
    /*
    require 'C:\PHPMailer\src\Exception.php';
    require 'C:\PHPMailer\src\PHPMailer.php';
    require 'C:\PHPMailer\src\SMTP.php';
    */
    
    /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */
    $mail = new PHPMailer(TRUE);
    
    /* Open the try/catch block. */
    try {
       //Enable SMTP debugging.
       $mail->SMTPDebug = 3;                               
       //Set PHPMailer to use SMTP.
       $mail->isSMTP();
       $mail->SMTPAutoTLS = true;
       //Set SMTP host name                          
       $mail->Host = "smtps.pec.aruba.it";
       //Set this to true if SMTP host requires authentication to send email
       $mail->SMTPAuth = true;                          
       //Provide username and password     
       $mail->Username = "areaverde@cert.azienda.it";                 
       $mail->Password = "super_secret_password";                           
       //If SMTP requires TLS encryption then set it
       $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;                           
       //Set TCP port to connect to
       $mail->Port = 465;
       /* Set the mail sender. */
       $mail->setFrom('darth@empire.com', 'Darth Vader');
    
       /* Add a recipient. */
       $mail->addAddress('mariorossi@pec.it', 'Emperor');
    
       /* Set the subject. */
       $mail->Subject = 'Force';
    
       /* Set the mail message body. */
       $mail->Body = 'There is a great disturbance in the Force.';
    
       /* Finally send the mail. */
       $mail->send();
    }
    catch (Exception $e)
    {
       /* PHPMailer exception. */
       echo $e->errorMessage();
    }
    catch (\Exception $e)
    {
       /* PHP exception (note the backslash to select the global namespace Exception class). */
       echo $e->getMessage();
    }
    Così che errore ti stampa?

  2. #2
    Ho risolto.
    In pratica lo script che utilizzo è quello che hai postato qui.
    Il problema credo, fosse, una vecchissima versione di phpmailer che utilizzavo.
    Adesso con la 6.5 che non è proprio l'ultima, ma almeno è "semplice" e funziona.
    Ora, ho un altro problema grande.
    Ammettendo il caso che il tizio che si è registrato, abbia digitato male la sua pec, come faccio attraverso phpmailer a dirgli che la sua mail non è stata inviata?

    Perché mettendo un indirizzo pec che non esiste, l'invio lo fa ugualmente.
    Poi, nella casella di chi invia arrivano due notifiche la prima di "avviso di mancata consegna" e l'altro "ricevuta di accettazione".
    Ma vorrei controllare che l'invio non è stato eseguito per la pec fake come si fa solitamente:
    Codice PHP:
    if($mail->send()){        echo "<div class='alert alert-success' role='alert'>Abbiamo inviato la tua mail.<br/>Puoi proseguire la navigazione.</div>";        }    else{        echo "<div class='alert alert-danger' role='alert'>Problemi invio</div>";    } 

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.