forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
5.0 KiB
120 lines
5.0 KiB
<?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ção não pode ser realizada! Email inválido.'); </script>"; |
|
} else if ($result) { |
|
//CHAMA A FUNÇÃ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ão enviado, verifique as configurações de E-mail!'); |
|
fecha_popup(); |
|
</script>"; |
|
} |
|
} else { |
|
echo "<script> alert('A operação não pode ser realizada! Verifica as configurações padrã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çã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ÇÃO DE E-MAIL |
|
<input name="id" type="hidden" id="id2" value="<?php |
|
if ($acao == 'edita') { |
|
echo $id; |
|
} |
|
?>" /> |
|
<input name="idMail" type="hidden" id="idMail" value="<?php echo $idMail; ?>"/> |
|
<input name="conta" type="hidden" id="conta" value="<?php echo $conta; ?>"/> |
|
<input name="dominio" type="hidden" id="dominio" value="<?php 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álido:</legend> |
|
<input name="email" type="text" class="caixas" id="email" value="<?php 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>
|
|
|