DanieleCalisti

PHPMailer

Oct 28th, 2020
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <?php
  2. /*
  3.     PRIMO METODO CHE NON FUNZIONA
  4.  
  5. require 'class.phpmailer.php';
  6.  
  7.  
  8. $mail = new PHPMailer();
  9.  
  10. $mail->IsSMTP();
  11. $mail->SMTPAuth = true;
  12. $mail->Host = "smtps.aruba.it";
  13. $mail->SMTPSecure = "ssl";          // Enable 'tls' encryption, `ssl` also accepted
  14. $mail->Port = 465;
  15. $mail->Username = "";
  16. $mail->Password = "****";
  17.  
  18.  
  19. //    EMAIL
  20.  
  21. $mail->SetFrom("[email protected]", 'Amministratore Utente (da Home)');
  22. $mail->Subject ='Email di prova con phpmailer';
  23.  
  24. $body = '<p>Testo della mail..</p>';
  25. $mail->MsgHTML($body);
  26. $mail->AddAddress("[email protected]","Nome");*/
  27.  
  28. //  SECONDO METODO CHE NON FUNZIONA
  29.  
  30. include("class.phpmailer.php");
  31.  
  32. $mittente = "[email protected]";
  33. $nomemittente = "Amministratore Utente (da Home)";
  34. $destinatario = "[email protected]";
  35. $ServerSMTP = "smtps.aruba.it";  //server SMTP
  36. $corpo_messaggio = "Grazie per averci contattato!!\n"
  37.     ."Cordiali Saluti,\nServizio Clienti";
  38.  
  39. $messaggio = new PHPMailer();
  40. // utilizza la classe SMTP invece del comando mail() di php
  41. $messaggio->IsSMTP();
  42. $messaggio->SMTPKeepAlive = "true";
  43. $messaggio->Host  = $ServerSMTP;
  44. $messaggio->From   = $mittente;
  45. $messaggio->FromName = $nomemittente;
  46. $messaggio->AddAddress($destinatario);
  47. $messaggio->Body = $corpo_messaggio;
  48. if(!$messaggio->Send()) {
  49.     echo "errore nella spedizione: ".$messaggio->ErrorInfo;
  50. } else {
  51.     echo "messaggio inviato correttamente";
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment