Codice PHP:
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
  
$mail->Host       "smtp.gmail.com"// SMTP server
  
$mail->SMTPDebug  2;                     // enables SMTP debug information (for testing)
  
$mail->SMTPAuth   false;                  // enable SMTP authentication
  
$mail->Host       "smtp.gmail.com"// sets the SMTP server
  
$mail->Port       26;                    // set the SMTP port for the GMAIL server
  
$mail->Username   "xxx"// SMTP account username
  
$mail->Password   "xxx";        // SMTP account password
  
$mail->AddReplyTo('name@yourdomain.com''First Last');
  
$mail->AddAddress($email_destinatario'John Doe');
  
$mail->SetFrom('name@yourdomain.com''First Last');
  
$mail->AddReplyTo('name@yourdomain.com''First Last');
  
$mail->Subject 'PHPMailer Test Subject via mail(), advanced';
  
$mail->AltBody 'To view the message, please use an HTML compatible email viewer!'// optional - MsgHTML will create an alternate automatically
  
$mail->MsgHTML(file_get_contents('file.html'));
  
$mail->AddAttachment('images/phpmailer.gif');      // attachment
  
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
  
$mail->Send();
  echo 
"Message Sent OK</p>\n";
} catch (
phpmailerException $e) {
  echo 
$e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
  echo 
$e->getMessage(); //Boring error messages from anything else!




mi da questi errori


SMTP -> FROM SERVER:
SMTP -> FROM SERVER: Method EHLO is not supported.
SMTP -> ERROR: EHLO not accepted from server: Method EHLO is not supported.
SMTP -> FROM SERVER:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedThe following From address failed: name@yourdomain.com