Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- system("command clear");
- //Contadores----------------------------------------------------------
- $GLOBALS['cont_ok'] = 1;
- $GLOBALS['cont_erro'] = 1;
- //--------------------------------------------------------------------
- //$comandos = argumentos($argv);
- //Configuração--------------------------------------------------------
- $GLOBALS['assunto'] = "informativo";
- $GLOBALS['email_remetente'] = "web3.luv.wordpress.com";
- $GLOBALS['eng_arq'] = "eng2.html";
- //--------------------------------------------------------------------
- function menu(){
- system("command clear");
- $menu="Ex: php script --assunto='Asunto do envio' --remetente='email@remetente' --eng=envio.html\r
- Ajuda: --ajuda\r
- Remetente: --remetente='seu remetente'\r
- Assunto do envio: --assunto='assunto'\r
- Eng: --eng=arquivo.html\r\n\r\n\r\n
- ";
- return $menu;
- }
- function conectart(){
- $host = 'IP.BANCO.MYSQL';
- $user = 'root';
- $senha = '102030';
- $banco = 'test';
- $link = mysql_connect($host, $user, $senha);
- $link = mysql_select_db($banco, $link);
- if (!$link) {
- die('ERRO : '.mysql_error());
- }
- }
- function msg($nome,$email,$cargo,$end,$data){
- if($GLOBALS['eng_arq'] != 'vazio'){
- $eng = file_get_contents($GLOBALS['eng_arq']);
- $eng = str_replace('NOME_ENG',$nome,$eng);
- $eng = str_replace('EMAIL_ENG',$email,$eng);
- $eng = str_replace('CARGO_ENG',$cargo,$eng);
- $eng = str_replace('END_ENG',$end,$eng);
- $eng = str_replace('DATA_ENG',$data,$eng);
- }
- return $eng;
- }
- function enviar($email,$assunto,$eng){
- $headers="From:Informativo <{$GLOBALS['email_remetente']}>\r\n";
- $headers.="MIME-Version: 1.0\r\n";
- $headers.= "X-Priority: 3 (Higuest)\r\n";
- $headers.= "X-MSMail-Priority: High\r\n";
- $headers.="Content-type: text/html; charset=iso-8859-1\r\n";
- $headers.="X-Mailer: PHP/".phpversion()."\r\n";
- if(filter_var($email, FILTER_VALIDATE_EMAIL)){
- if(mail($email,$assunto,$eng,$headers)){
- echo $GLOBALS['cont_ok']++." - {$email} - [OK]ENVIADO!\r\n";
- }
- else{
- echo $GLOBALS['cont_erro']++." - {$email} - [NO]ENVIADO!\r\n";
- }
- }
- else{
- echo $GLOBALS['cont_erro']++." - {$email} - EMAIL INVALIDO!\r\n";
- }
- }
- function processo(){
- echo "REMETENTE: {$GLOBALS['email_remetente']}\r\n";
- echo "ENG: {$GLOBALS['eng_arq']}\r\n";
- echo "ASSUNTO: {$GLOBALS['assunto']}\r\n\r\n";
- conectart();
- $result = mysql_query('SELECT * FROM envio');
- if (!$result) {
- die('ERRO!:' . mysql_error());
- }
- while($escrever=mysql_fetch_array($result)){
- $eng=msg($escrever['nome'],$escrever['email'],$escrever['cargo'],$escrever['end'],$escrever['data']);
- echo enviar($escrever['email'],$GLOBALS['assunto'],$eng)."\r\n";
- sleep(1);
- }
- $GLOBALS['cont_ok']= $GLOBALS['cont_ok'] - 1;
- $GLOBALS['cont_erro']= $GLOBALS['cont_erro'] - 1;
- echo "TOTAL: {$GLOBALS['cont_ok']}\r\n";
- echo "TOTAL ERRO: {$GLOBALS['cont_erro']}\r\n";
- }
- echo menu();
- processo();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement