<?

    require("class.phpmailer.php"); 
	include('main.php'); 
	header("location: tksupnews.html");
		
	function descricao_pais($cod_pais)
    {
	   $dpais = '';
       $sql = "select descricao from tbpais where cod_pais = '$cod_pais'";          
       $result = mysql_query($sql) or die("erro na pesquisa de pais");

		if ($row = mysql_fetch_row($result))
			$dpais = $row[0];
			
		return $dpais;		
	}

    function envio_newsletter()
    {       
		$nome      = $_POST["nome"];
		$email     = $_POST["email"];
		$telefone  = $_POST["telefone"];
		$language  = $_POST["language"];	
		$pais      = $_POST["pais"];	
						        
        $msg="<html><body><br>
		Nome: ".$nome."<br><br>
		E-mail:".$email."<br><br>
		Telefone:".$telefone."<br><br>		
		Idioma:".$language."<br><br>
		Pais:".$pais."<br>
		</body></html>";

        $email_rentacar = 'informatica@bravacar.com.pt';
              
        if ($email_rentacar != '')
        {            
            
			$mail = new PHPMailer();
            $mail->IsSMTP();                                 // send via SMTP
            $mail->Host     = "127.0.0.1";                   // SMTP servers
            $mail->SMTPAuth = true;                          // turn on SMTP authentication
            $mail->Username = "informatica@bravacar.com.pt"; // um endereo e-mail valido deste dominio
            $mail->Password = "london";                      // senha desse endereo e-mail valido deste dominio    

            $mail->From     = NEWSLETTER_EMAIL;            
            $mail->FromName = "Newsletter - Bravacar";             
            $mail->AddAddress(NEWSLETTER_EMAIL);          
                       
            $mail->WordWrap = 50;                            // set word wrap
            $mail->IsHTML(true);                             // send as HTML            

            $mail->Subject  =  "Subscrição Cliente Newsletter - Bravacar - Rent a car";

            $mail->Body     =  $msg;
            $mail->AltBody  =  "";
            
            if(!$mail->Send())
            {
                echo "Mail no enviado <p>";
                echo "Erro: " . $mail->ErrorInfo;
                exit;
            }
            
			$mail->SmtpClose();

         }
    }
	
	envio_newsletter();

?>
