Ir para conteúdo

malufla79

Members
  • Total de itens

    2
  • Registro em

  • Última visita

Posts postados por malufla79


  1. Boa tarde, estou com probleminha no phpmailer, o código abaixo funciona corretamente quando consigo enviar para um único e-mail, mas quando coloco a opção todos, ele só manda apenas para primeiro e-mail e não apresenta nenhum erro. Poderia me dar uma ajudinha? Obrigada

     

    Controle

    if ($_POST['filtro'] == 'todos') {
                    // essa consulta pego a lista de e-mails cadastrado no meu banco de dados
                    $usuarios->consultar("select * from mala_email");
                    $linha = $usuarios->Linha;
                    $rs = $usuarios->Result;
                }
    
    if ($_POST['filtro'] == 'todos') {
          for ($i=0; $i<$linha; $i++) {
              $email = $rs[$i]['email'];
              $mensagem = $_POST['editor'];	
    			
              $util->EnviarEmaiLivre($email, utf8_decode($_POST['assunto']), $mensagem);
    							
           }
            
    } else {
           $mensagem = $_POST['editor'];
           $util->EnviarEmaiLivre($_POST['email'], utf8_decode($_POST['assunto']), $mensagem);
    }

    Função

    function EnviarEmaiLivre($email, $assunto, $mensagem) {
    
            date_default_timezone_set('Etc/UTC');
    
            require 'phpmailer/PHPMailerAutoload.php';
    
            $hostSmtp = "mail.domino.com.br";
            $smtpUser = "email@email.com.br";
            $senhaSmtp = "********";
    		
    		$mensagem = ' <p><img src="http://www.dominio.com.br/images/logodolugar.png" alt="Logo do Lugar" width="550"></p> '.$mensagem;		
    		
    		//Create a new PHPMailer instance
            $mail = new PHPMailer;
    
    		//Tell PHPMailer to use SMTP
            $mail->isSMTP();
    
    		//Enable SMTP debugging
    		// 0 = off (for production use)
    		// 1 = client messages
    		// 2 = client and server messages
    		$mail->SMTPDebug = 0;
    		
    		//Ask for HTML-friendly debug output
            $mail->Debugoutput = 'html';
    
    		//Set the hostname of the mail server
            $mail->Host = $hostSmtp;
    		// use
    		// if your network does not support SMTP over IPv6
    		//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
            $mail->Port = 587;
    
    		//Set the encryption system to use - ssl (deprecated) or tls
            $mail->SMTPSecure = 'tsl';
    
    		//Whether to use SMTP authentication
            $mail->SMTPAuth = true;
    
    		//Username to use for SMTP authentication - use full email address for gmail
            $mail->Username = $smtpUser;
    
    		//Password to use for SMTP authentication
            $mail->Password = $senhaSmtp;
    
    		//Set who the message is to be sent from
            $mail->setFrom('email@email.com.br', 'E-mail do Lugar');
    
    		//Set who the message is to be sent to
            
    		$mail->addAddress($email);
    		
    
    		//Set the subject line
            $mail->Subject = $assunto;
    
    		//Replace the plain text body with one created manually
    	    $mail->Body = $mensagem;
            $mail->isHTML(true);
    
            if ($conteudoArquivo != '' && $arquivo != '') {
    			//Attach an image file
                $mail->addAttachment('phpmailer/images/phpmailer_mini.png');
    			
                //Read an HTML message body from an external file, convert referenced images to embedded,
    			//convert HTML into a basic plain-text alternative body
                $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
            }
    
            if (!$mail->send()) {
               $retorno = false;
            } else {
               $retorno = true;
            }
    		
        }

     

     


  2. Boa tarde, estou com probleminha no phpmailer, o código abaixo funciona corretamente quando consigo enviar para um único e-mail, mas quando coloco a opção todos, ele só manda apenas para primeiro e-mail e não apresenta nenhum erro. Poderia me dar uma ajudinha? Obrigada

     

    Controle

    if ($_POST['filtro'] == 'todos') {
                    // essa consulta pego a lista de e-mails cadastrado no meu banco de dados
                    $usuarios->consultar("select * from mala_email");
                    $linha = $usuarios->Linha;
                    $rs = $usuarios->Result;
                }
    
    if ($_POST['filtro'] == 'todos') {
          for ($i=0; $i<$linha; $i++) {
              $email = $rs[$i]['email'];
              $mensagem = $_POST['editor'];	
    			
              $util->EnviarEmaiLivre($email, utf8_decode($_POST['assunto']), $mensagem);
    							
           }
            
    } else {
           $mensagem = $_POST['editor'];
           $util->EnviarEmaiLivre($_POST['email'], utf8_decode($_POST['assunto']), $mensagem);
    }

    Função

    function EnviarEmaiLivre($email, $assunto, $mensagem) {
    
            date_default_timezone_set('Etc/UTC');
    
            require 'phpmailer/PHPMailerAutoload.php';
    
            $hostSmtp = "mail.domino.com.br";
            $smtpUser = "email@email.com.br";
            $senhaSmtp = "********";
    		
    		$mensagem = ' <p><img src="http://www.dominio.com.br/images/logodolugar.png" alt="Logo do Lugar" width="550"></p> '.$mensagem;		
    		
    		//Create a new PHPMailer instance
            $mail = new PHPMailer;
    
    		//Tell PHPMailer to use SMTP
            $mail->isSMTP();
    
    		//Enable SMTP debugging
    		// 0 = off (for production use)
    		// 1 = client messages
    		// 2 = client and server messages
    		$mail->SMTPDebug = 0;
    		
    		//Ask for HTML-friendly debug output
            $mail->Debugoutput = 'html';
    
    		//Set the hostname of the mail server
            $mail->Host = $hostSmtp;
    		// use
    		// if your network does not support SMTP over IPv6
    		//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
            $mail->Port = 587;
    
    		//Set the encryption system to use - ssl (deprecated) or tls
            $mail->SMTPSecure = 'tsl';
    
    		//Whether to use SMTP authentication
            $mail->SMTPAuth = true;
    
    		//Username to use for SMTP authentication - use full email address for gmail
            $mail->Username = $smtpUser;
    
    		//Password to use for SMTP authentication
            $mail->Password = $senhaSmtp;
    
    		//Set who the message is to be sent from
            $mail->setFrom('email@email.com.br', 'E-mail do Lugar');
    
    		//Set who the message is to be sent to
            
    		$mail->addAddress($email);
    		
    
    		//Set the subject line
            $mail->Subject = $assunto;
    
    		//Replace the plain text body with one created manually
    	    $mail->Body = $mensagem;
            $mail->isHTML(true);
    
            if ($conteudoArquivo != '' && $arquivo != '') {
    			//Attach an image file
                $mail->addAttachment('phpmailer/images/phpmailer_mini.png');
    			
                //Read an HTML message body from an external file, convert referenced images to embedded,
    			//convert HTML into a basic plain-text alternative body
                $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
            }
    
            if (!$mail->send()) {
               $retorno = false;
            } else {
               $retorno = true;
            }
    		
        }

     

     

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.