knowledge base di supporto per i servizi NewMediaLabs                                 Pensa a un dominio:    

Invia per email
* Il tuo nome:
* La tua email:
* Email destinatario:
Commento:


Invio Email dal sito (con PhpMailer per php5)

<?php

function sendMail($from, $subject, $body, $to, $debug, $attach){
require_once("include/mailPx/class.phpmailer.php");
  $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  if($debug){
    //require_once("class.smtp.php");
    try {
  $mail->IsSMTP();  
  $mail->SMTPDebug  = 2;   // enables SMTP debug information (for testing)
                                 // 1 = errors and messages
                                // 2 = messages only
  $mail->SMTPAuth   = true;                  // enable SMTP authentication
  $mail->Host       = "mail.DOMINIO"; // sets the SMTP server
  $mail->Port       = 25;                    //  
  $mail->Username   = "admin@DOMINIO"; // SMTP account username
  $mail->Password   = "PASSWORD";        // SMTP account password
  $mail->AddReplyTo($from, 'DOMINIO');
  $mail->AddAddress($to, 'Gentile Cliente');
  $mail->SetFrom($from, 'DOMINIO');
  $mail->Subject = $subject;
  $mail->AltBody = strip_tags(str_replace('<br>','\n',$body)); // optional - MsgHTML will create an alternate automatically
  $mail->MsgHTML($body);
  $mail->IsHTML(true);
  if($attach!=""){
   $mail->AddAttachment($attach);
  }
  $mail->Send();
  echo "ok";
  } catch (phpmailerException $e) {
   echo $e->errorMessage(); //Pretty error messages from PHPMailer
  } catch (Exception $e) {
   echo $e->getMessage(); //Boring error messages from anything else!
  }
 
}
}
sendMail("admin@Dominio.ext", "XXXXXXX: soggetto", "messaggio<br>xxxxxxxxx", "emaildestinatario@dominiodestinatario", 1 ,'');

?>



RSS