derevandal

Untitled

Dec 19th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.64 KB | None | 0 0
  1. <?php
  2. require_once("./includer/strings.class.php");
  3. class RHFunc{
  4.  
  5.     var $RH_Mysql;
  6.     var $RH_Strings;
  7.    
  8.     public function __construct(){
  9.         $this->RH_Strings = new RHStrings();
  10.     }
  11.  
  12.     public function FormContato($Nome, $Email, $Telefone, $Mensagem){
  13.         if(isset($Nome) && isset($Email) && isset($Telefone) && isset($Mensagem)){
  14.             $msg = "<h2>Formulário de contato acionado</h2><br><strong>Nome:</strong> ".$Nome."<br><strong>E-mail:</strong> ".$Email."<br><strong>Telefone</strong>: ".$Telefone."<br><strong>Mensagem:</strong> ".$Mensagem."<br><br><br><small>Este e-mail foi gerado pelo sistema de contato, portanto, não responda para este e-mail.</small>";
  15.             $msg .= "<br>----------------------------";
  16.             $msg .= "<br>";
  17.             $msg .= "Enviado em <strong>".date("h:m:i d/m/Y")." por ".$_SERVER['REMOTE_ADDR']."</strong>"; //mostra a data e o IP
  18.             $msg .= "<br>";
  19.             $msg .= "----------------------------";
  20.  
  21.             require("class.phpmailer.php");
  22.             $mail = new PHPMailer();
  23.  
  24.             $mail->IsSMTP(); // telling the class to use SMTP
  25.  
  26.             try {
  27.                
  28.                 $mail->SMTPDebug  = $this->RH_Strings->Contato[6]; // enables SMTP debug information (for testing)
  29.                 $mail->Host       = $this->RH_Strings->Contato[3]; // sets the SMTP server
  30.                 $mail->Port       = $this->RH_Strings->Contato[4]; // set the SMTP port for the GMAIL server
  31.                 $mail->SMTPAuth   = true; // enable SMTP authentication
  32.                 $mail->Username   = $this->RH_Strings->Contato[0]; // SMTP account username
  33.                 $mail->Password   = $this->RH_Strings->Contato[2]; // SMTP account password
  34.  
  35.                 $mail->SetFrom($this->RH_Strings->Contato[0], $this->RH_Strings->Contato[1]);
  36.                 $mail->AddAddress($this->RH_Strings->Contato[8], $this->RH_Strings->Contato[9]);
  37.  
  38.                 $mail->Subject = $this->RH_Strings->Contato[5];
  39.                 $mail->MsgHTML($msg);
  40.                 $mail->Send();
  41.  
  42.  
  43.                 echo "SMTPDebug  = ".$this->RH_Strings->Contato[6]."<br>
  44.                 Host  = ".$this->RH_Strings->Contato[3]."<br>
  45.                 Port  = ".$this->RH_Strings->Contato[4]."<br>
  46.                 SMTPAuth  = ".$this->RH_Strings->Contato[7]."<br>
  47.                 Username  = ".$this->RH_Strings->Contato[0]."<br>
  48.                 Password  = ".$this->RH_Strings->Contato[2]."<br>
  49.  
  50.                 SetFrom   = ".$this->RH_Strings->Contato[0], $this->RH_Strings->Contato[1]."<br>
  51.                 AddAddress   = ".$this->RH_Strings->Contato[8], $this->RH_Strings->Contato[9]."<br>
  52.  
  53.                 Subject = ".$this->RH_Strings->Contato[5]."<br>
  54.                 Mensagem = ".$msg."<br>";
  55.  
  56.                 return true;
  57.             } catch (phpmailerException $e) {
  58.                 echo $e->errorMessage(); //Pretty error messages from PHPMailer
  59.             } catch (Exception $e) {
  60.                 echo $e->getMessage(); //Boring error messages from anything else!
  61.             }
  62.             return false;
  63.         }
  64.     }
  65. }
  66. ?>
Add Comment
Please, Sign In to add comment