Viewing file: enviar_mensalidades_email.php (5.76 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?header('Content-Type: text/html; charset=iso-8859-1');?> <?php include("../../config/config.php"); include(INCLUDES . "conexaoBD.php"); include(INCLUDES . "sentencas_sql.php"); include(INCLUDES . "funcoes_uteis.php"); include(INCLUDES . "valida_usuario.inc.php"); include("boletos_class.php"); require __DIR__ . '/vendor/autoload.php'; use mikehaertl\wkhtmlto\Pdf;
$urlPhpMailer = dirname(__FILE__) . "/phpmailer/PHPMailer.php"; require_once($urlPhpMailer);
function clean($str) { $trimmed = trim($str); return urlencode($trimmed); }
//Funções function EnviaEmailOficio($assunto, $texto, $email_destino, $email_destino2, $anexo) { //$email_destino = "mira@mirasistemas.com.br"; $corpo_email = "<html> <head> <title>$assunto</title> <style type=\"text/css\"> body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; text-align: justify; width: 640px; max-width: 640px; margin: auto; } </style> </head> <body>" . stripslashes($texto) . " </body> </html>";
$mail = new PHPMailer; $mail->From = 'contato@arpenpr.org.br'; $mail->FromName = 'Contato - IRPEN'; $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.arpenpr.org.br'; $mail->SMTPAuth = true; $mail->Username = "smtp@arpenpr.org.br"; $mail->Password = "MydbRokoIrpE1$"; $mail->IsHTML(true); $mail->Subject = $assunto; $mail->AddAddress($email_destino); if($email_destino2) $mail->AddAddress($email_destino2); $mail->Body = $corpo_email; $mail->AddAttachment($anexo); //$mail->AddBCC("mira@mirasistemas.com.br"); $rs = $mail->Send(); return $rs;
}
$assunto = "MENSALIDADE IRPEN - OUT/2022";
$sql = "SELECT SVB_RowID, CON_CPF, CON_Descricao,CID_Descricao, OFI_Endereco, OFI_Cep, OFI_DDD, OFI_Fone, DATE_FORMAT(SVB_DataVencimento, '%d/%m/%Y') AS SVB_DataVencimento, SVB_Valor, CON_Email, CON_Email2, OFI_RowID, CON_RowID, SVB_NossoNumeroWS, OFI_Descricao, OFI_CNPJ, SVB_RowID FROM irp_servicos_mensalidades INNER JOIN irp_servicos_boletos ON SRM_RowID = SVB_Mensalidade_DR INNER JOIN contatos ON CON_Oficios_DR = SRM_Oficio_DR INNER JOIN oficios ON OFI_RowID = SRM_Oficio_DR INNER JOIN cidades ON CID_RowID = OFI_Cidades_DR WHERE CON_AtivoSN = 'S' AND SVB_EntradaConfirmadaRegistroSN = 'S' AND SVB_BoletoRegistradoSN = 'S' and DATE_FORMAT(SVB_DataVencimento, '%d/%m/%Y') = '10/10/2022' AND SVB_PagoSN = 'N' AND SVB_EmailEnviado <> 0 limit 1";
$rsOfi = $conexao->query($sql);
while($email_oficio = $rsOfi->fetch_array()) { $idx = $email_oficio["SVB_RowID"]; $cod_oficio = $email_oficio["OFI_RowID"]; $cod_contato = $email_oficio["CON_RowID"]; $email_contato = 'oscar@roko.com.br';//$email_oficio["CON_Email"]; $email_contato2 = 'oscar@roko.com.br';//$email_oficio["CON_Email2"]; $codBoleto = $email_oficio["SVB_RowID"]; $dtVencimento = $email_oficio["SVB_DataVencimento"]; $valor = $email_oficio["SVB_Valor"]; $nossoNumero = $email_oficio["SVB_NossoNumeroWS"]; $oficio = $email_oficio["OFI_Descricao"]; $endereco = $email_oficio["OFI_Endereco"]; $cep = $email_oficio["OFI_Cep"]; $cidade = $email_oficio["CID_Descricao"]; $cnpj = $email_oficio["OFI_CNPJ"];
$texto = "<p>Prezados Registradores Civis Paranaenses,<br /> <br /> O XXVIII Congresso Nacional de Registro Civil - Conarci2022 - será realizado nos dias 13, 14 e 15 de outubro de 2022, </p> em São Paulo, capital, com público presencial e transmissão on-line para participantes de todo o país.</p> </p> </p> </p> Confira a programação completa em https://www.conarci2022.com.br/#/ </p> </p> Diretoria IRPEN.</p> ";
$url = "http://arpenpr.org.br/admin/boletos/gerar.php?data_venc=$dtVencimento&valor=$valor&nosso_numero=$nossoNumero&nome=" . clean($oficio) . "&endereco=" . clean($endereco) . "&cep=$cep&cidade=". clean($cidade) . "&CNPJCPFSacado=$cnpj&texto=" . clean($assunto);
$file_name = "boleto_" . $nossoNumero;
if(file_put_contents( $file_name . ".html",file_get_contents($url))) {
$pdf = new Pdf($file_name . ".html"); if (!$pdf->saveAs($file_name . ".pdf")) { $error = $pdf->getError(); echo $error; // ... handle error here } else { $ret = null; $ret = EnviaEmailOficio($assunto, $texto, $email_contato, $email_contato2, $file_name . ".pdf"); if($ret == 1) { $sqlz = "UPDATE irp_servicos_boletos SET SVB_EmailEnviado = 0 WHERE SVB_RowID = $idx"; $conexao->query($sqlz); $conexao->commit(); } else { echo "Erro eo enviar Email... " . $email_contato; } }
} else { echo "File downloading failed."; }
//die(); sleep(1);
}
?>
|