PHP - Problema con mensaje en codigo

 
Vista:

Problema con mensaje en codigo

Publicado por zendi (117 intervenciones) el 01/11/2018 21:31:24
Tengo este codigo que diseñé para enviar archivos a correos masivos.
El codigo en realidad envia el archivo, pero no muestra el mensaje que esta en NEGRITA( $respuesta ="El Documento ha sido enviado a los Propietarios";), una vez que lo envia da un pantallazo en blanco. Si alguien pudiera ayudarme en este caso.
El debiera entrar despues del
1
else

1
2
3
4
5
6
7
8
9
10
if (!$smtp->Send())
{
    $respuesta ="El Documento no se pudo enviar";
    $respuesta .="Error: " .$smtp->ErrorInfo;
 
}
else
{
    $respuesta ="El Documento ha sido enviado a los Propietarios";
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
$connect = pg_connect("host=localhost port=5432 dbname=administra user=postgres password=Wjap*/1900");
require("PHPMailer-master/class.phpmailer.php");
require("PHPMailer-master/class.smtp.php");
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
$de = $_POST["de_txt"];
$para = $_POST["para_txt"];
$asunto = $_POST["asunto"];
$archivo = $_FILES["archivo_fls"]["tmp_name"];
$selected_radio = $_POST['gender'];
$destino = $_SERVER['DOCUMENT_ROOT']."/".$_FILES["archivo_fls"]["name"];
//echo $_SERVER['DOCUMENT_ROOT'];
$mensaje = $_POST["mensaje_txa"];
if(move_uploaded_file($archivo,$destino))
{
	$smtp=new PHPMailer();
	# Indicamos que vamos a utilizar un servidor SMTP 
	$smtp->IsSMTP();
	# Definimos el formato del correo con UTF-8 
	$smtp->CharSet="UTF-8";
//	$smtp->SMTPDebug = 1; 
	# autenticación contra nuestro servidor smtp 
	$smtp->SMTPAuth = true; // enable SMTP authentication
	$smtp->SMTPSecure = "tls";
	$smtp->Host = "smtp.live.com";
	// sets MAIL as the SMTP server
	$smtp->Username = "ald_mir@hotmail.com";
	// MAIL username
	$smtp->Password = "Wrap*/1808";
	// MAIL password 
	$smtp->Port = 587;
	# datos de quien realiza el envio 
	$smtp->From = "ald_mir@hotmail.com";
	// from mail 
	$smtp->FromName = "Aldon";
	// from mail name # Indicamos la dirección donde enviar el mensaje 
/*	$para="andresmen2004@hotmail.com";
	$nameTo="Andres";
	$smtp->AddAddress($para,$nameTo); */
  $smtp->Subject = $asunto;
  $smtp->Body = $mensaje;
	$smtp->WordWrap = 50;
	$smtp->Timeout=30;
	$smtp->IsHTML(true);
	$smtp->MsgHTML("mensaje");
	$smtp->AddAttachment($destino, $_FILES["archivo_fls"]["name"]);
  $connect = pg_connect("host=localhost port=5432 dbname=administra user=postgres password=Wjap*/1900");
/*se crea el array o query que debe traer tanto el nombre como la cuenta de correos*/
        if ($selected_radio == 'male') {
            $male_status = 1.08191;
            $mailTo = "SELECT nombres,cta_correo FROM propietarios WHERE alicuota = $male_status";
        }
        else if ($selected_radio == 'female') {
            $female_status = 2.03111;
            $mailTo = "SELECT nombres,cta_correo FROM propietarios WHERE alicuota = $female_status";
        }
        else if ($selected_radio == 'other') {
            $other_status = 0;
            $mailTo = "SELECT nombres,cta_correo FROM propietarios WHERE alicuota = $other_status";
        }
    $mailTo = @pg_query($connect,$mailTo);
          while($select3 = @pg_fetch_array($mailTo))
               {
                $name = $select3['nombres'];
          	    $mail = $select3['cta_correo'];
 
                $smtp->ClearAllRecipients();
                $smtp->AddAddress($mail,$name);
 
                   if (!$smtp->Send())
                      {
                         $respuesta ="El Documento no se pudo enviar";
                         $respuesta .="Error: " .$smtp->ErrorInfo;
 
                  	  }
                	 else
                  	  {
                    	 $respuesta ="El Documento ha sido enviado a los Propietarios";
                	    }
               }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="estilo.css" type="text/css">
<style type="text/css">
  .sr {
    background-color: #FFFFCF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
    text-align:center;
      }
  input.color1 {background-color: #00CC99; font-weight: bold; font-size: 12px; color: white;}
 
  form { margin: 1em auto; text-align: center; }
   span{ color: #F60; font-size: 1.5 em; } 
  </style>
</head>
<body> <b>
<?php echo $respuesta;?>
</b>
<form name="mail_frm" method="post" class="contact_form" id='formulario' enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]?>">
                <ul>
                <li>
                    <h2>Cont&aacute;cto</h2>
                </li>
            <li>
<!--             <label for="name">De:</label>
-->			 <input type="text" name="de_txt" id='De' placeholder="ald_mir@hotmail.com" disabled="true">
                <span class="form_hint">Formato correcto:  "ejemplo@hotmail.com"</span>
            </li>
 
            <li>
<!--             <label for="name">Asunto:</label>-->
              <input type="text" name="asunto" id="Asunto" placeholder="Asunto" required >
              <span class="form_hint">Formato correcto: "Asunto"</span>
		    </li>
 
            <li>
<!--             <label for="name">Adjuntar Archivo: </label>-->
              <input type="file" name="archivo_fls" id="Adjuntar Archivo" placeholder="Adjuntar Archivo" required/>
              <span class="form_hint">Formato correcto: "Adjuntar Archivo"</span>
		    </li>
            <li>
           <Input type = 'radio' name ='gender' value= 'male'/>
              1.08191
            </li>
            <li>
                <Input type = 'radio' name ='gender' value= 'female'/>
               2.03111
            </li>
            <td class="sr"><li>
                <Input type = 'radio' Name ='gender' value= 'Other'/>
                    Sin Alicuota
            </li></td>
            <li>
<!--             <label for="name">Mensaje:</label>-->
<!--      Mensaje:<br />-->
      <textarea name="mensaje_txa" cols="40" rows="6" placeholder="Mensaje"></textarea>
<!--           <textarea name="mensaje" cols="40" rows="6" placeholder="Ingresa un mensaje (opcional)"></textarea>
 -->              <span class="form_hint">Formato correcto: "Mensaje"</span>
		    </li>
            <li align='center'>
                <button class="submit" type='submit' value='Enviar formulario'>Enviar Mensaje</button>
                <button class="submit" type='reset' value='Reiniiar formulario'>Borrar Datos</button>
 
            </li>
</ul>
<!--  <input type="submit" name="enviar_btn" value="Enviar"/><br/> 
-->  </form>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Problema con mensaje en codigo

Publicado por xve (6935 intervenciones) el 02/11/2018 07:27:44
Hola Zendi, pero que error te muestra?
Si no entra en ese else entrara en el if que muestra el error, no?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Problema con mensaje en codigo

Publicado por zendi (117 intervenciones) el 05/11/2018 20:35:32
No muestra absolutamente nada en el else, aparece solo la pantalla en blanco. Y cuando entra al if si aparece
1
$respuesta ="El Documento no se pudo enviar";
Es una locura esto.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar