|
|
|
|
<?php
|
|
|
|
|
require("phpmailer/class.phpmailer.php");
|
|
|
|
|
|
|
|
|
|
$form = IsPostBack() ? $_POST : $_GET;
|
|
|
|
|
|
|
|
|
|
$conta = $form['conta'];
|
|
|
|
|
$dominio = $form['dominio'];
|
|
|
|
|
$email = $form['email'];
|
|
|
|
|
$idMail = $form['idMail'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsPostBack()) {
|
|
|
|
|
$query = "select hosts, usuario, senha, porta, tsl
|
|
|
|
|
from pbx_confmail where id = $idMail";
|
|
|
|
|
$result = @pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
if (!is_email($email)) {
|
|
|
|
|
echo "<script> alert('A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada! Email inv<EFBFBD>lido.'); </script>";
|
|
|
|
|
} else if ($result) {
|
|
|
|
|
//CHAMA A FUN<EFBFBD><EFBFBD>O PARA ENVIO DO EMAIL TESTE
|
|
|
|
|
$testeEnvio = enviaMail($result, $email, $conta);
|
|
|
|
|
if ($testeEnvio == true) {
|
|
|
|
|
echo "<script>
|
|
|
|
|
alert('Teste enviado!');
|
|
|
|
|
fecha_popup();
|
|
|
|
|
</script>";
|
|
|
|
|
} else {
|
|
|
|
|
echo "<script>
|
|
|
|
|
alert('Teste n<EFBFBD>o enviado, verifique as configura<EFBFBD><EFBFBD>es de E-mail!');
|
|
|
|
|
fecha_popup();
|
|
|
|
|
</script>";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo "<script> alert('A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada! Verifica as configura<EFBFBD><EFBFBD>es padr<EFBFBD>o.'); </script>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function enviaMail($result, $email, $conta) {
|
|
|
|
|
$enviado = false;
|
|
|
|
|
|
|
|
|
|
while ($dados = @pg_fetch_array($result)) {
|
|
|
|
|
|
|
|
|
|
$mail = new PHPMailer();
|
|
|
|
|
$mail->IsSMTP();
|
|
|
|
|
$mail->Host = $dados["hosts"];
|
|
|
|
|
$mail->Port = $dados["porta"];
|
|
|
|
|
$mail->SMTPAuth = $dados["usuario"] != "";
|
|
|
|
|
$mail->SMTPSecure = $dados['tsl'] == "on";
|
|
|
|
|
|
|
|
|
|
if ($mail->SMTPAuth) {
|
|
|
|
|
/*
|
|
|
|
|
* Autentica<EFBFBD><EFBFBD>o smtp
|
|
|
|
|
*/
|
|
|
|
|
$mail->Username = $dados["usuario"];
|
|
|
|
|
$mail->Password = $dados["senha"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mail->From = $dados["usuario"];
|
|
|
|
|
$mail->FromName = $conta;
|
|
|
|
|
$mail->AddAddress($email);
|
|
|
|
|
$mail->IsHTML(true);
|
|
|
|
|
$mail->CharSet = 'iso-8859-1';
|
|
|
|
|
$mail->Subject = "Teste de Envio";
|
|
|
|
|
$mail->Body = "Conta SMTP configurada com sucesso!";
|
|
|
|
|
$mail->AltBody = "Conta SMTP configurada com sucesso!";
|
|
|
|
|
$enviado = $mail->Send();
|
|
|
|
|
$mail->ClearAllRecipients();
|
|
|
|
|
$erro = $mail->ErrorInfo;
|
|
|
|
|
}
|
|
|
|
|
return $enviado;
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
|
|
|
|
|
<head>
|
|
|
|
|
<title>Simples IP</title>
|
|
|
|
|
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
|
|
|
<script src="admin/js/pbxAjax.js" type="text/javascript"></script>
|
|
|
|
|
<style type="text/css">
|
|
|
|
|
<!--
|
|
|
|
|
body {
|
|
|
|
|
background-color: #E6E6E6;
|
|
|
|
|
}
|
|
|
|
|
-->
|
|
|
|
|
</style></head>
|
|
|
|
|
<body>
|
|
|
|
|
<form name="form1" method="post" action="index.php?idProg=11140&pbxRequest=1" id="form1">
|
|
|
|
|
<table border="1" align="center" cellpadding="0" cellspacing="0" class="tabela">
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td width="406" height="21"><div align="center" class="cabecalho">TESTE DE CONFIGURA<EFBFBD><EFBFBD>O DE E-MAIL
|
|
|
|
|
<input name="id" type="hidden" id="id2" value="<?
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $id;
|
|
|
|
|
}
|
|
|
|
|
?>" />
|
|
|
|
|
<input name="idMail" type="hidden" id="idMail" value="<? echo $idMail; ?>"/>
|
|
|
|
|
<input name="conta" type="hidden" id="conta" value="<? echo $conta; ?>"/>
|
|
|
|
|
<input name="dominio" type="hidden" id="dominio" value="<? echo $dominio; ?>"/>
|
|
|
|
|
</div></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td height="31" class="labels"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
|
|
<tr>
|
|
|
|
|
<td width="47%"><fieldset>
|
|
|
|
|
<legend class="labels">Digite um email V<EFBFBD>lido:</legend>
|
|
|
|
|
<input name="email" type="text" class="caixas" id="email" value="<? echo $email; ?>" size="55" maxlength="100" />
|
|
|
|
|
</fieldset></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF">
|
|
|
|
|
<td align="center" colspan="2" bordercolor="#FFFFFF" style="border-color:#FFFFFF">
|
|
|
|
|
<input type="submit" value="Testar">
|
|
|
|
|
<button id="volta" onclick="fecha_popup();">Fechar</button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table></div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|