knowledge base di supporto per i servizi NewMediaLabs                                 Pensa a un dominio:    
Cerca:     Ricerca avanzata
Sfoglia per categorie:

Invio Email dal sito (con PhpMailer per php5)

Visite: 2756
Voti: 0
Posted: 23 gen, 2010
by: Admin A.
Updated: 01 set, 2011
by: Admin A.

<?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 ,'');

?>
Altro in questa categoria
document Come si effettua l'upload dei files via PHP?
document Cdosys, formMail in asp per Hosting Windows Rubalo.it
document E’possibile utilizzare PEAR per l’autenticazione email su hosting linux?
document E' possibile effettuare modifiche al php.ini?
document Perchè ottengo l'errore "500 - Internal server error" ?
document Posso installare Wordpress su hosting Windows?



RSS