Problem sending mail with PHP

0

I am trying to send a mail just after inserting records in the database.

But it seems that the PDO has some conflict with the mail () statement, since the PDO works perfectly (without sending the mail)

But when entering the line of code to send the mail, nothing of code is executed ..

only shows me Page Error:

  

This page does not work platform.mx can not process this request   at this time. HTTP ERROR 500

This is my code:

if ($departamento === "True") { 

        try { 
        /* Creamos La Conexión con PDO, modificar los valores respectivos*/
        $bd = new PDO('mysql:host=localhost;dbname=xxx',"xxx", "xxx",array(PDO::ATTR_PERSISTENT => true));
        $bd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        /* Creamos la Transacción*/
        $bd->beginTransaction();
        /* Preparamos la Sentencia*/
        $sentencia = $bd->prepare("INSERT INTO temporal8 (articulo,fraccion,inciso,nombre,documento,ano,departamento,rango_actualizacion,fecha_actualizacion,consecutivo,mes,ruta) VALUES (:articulo,:fraccion,:inciso,:nombre,:documento,:ano,:departamento,:rango_actualizacion,:fecha_actualizacion,:consecutivo,:mes,:ruta)")or die("fallo al insertar datos: ".mysqli_error($link));
        /* Le pasamos el valor fijo antes de entrar al For */
        $sentencia->bindValue(':articulo', $articulo, PDO::PARAM_STR);
        $sentencia->bindValue(':fraccion', $fraccion, PDO::PARAM_STR);
        $sentencia->bindValue(':inciso', $inciso, PDO::PARAM_STR);
        $sentencia->bindValue(':nombre', $nombre, PDO::PARAM_STR);
        $sentencia->bindValue(':documento', $nombreDoc, PDO::PARAM_STR);
        $sentencia->bindValue(':ano', $ano, PDO::PARAM_STR);
        $sentencia->bindValue(':rango_actualizacion', $rango, PDO::PARAM_STR);
        $sentencia->bindValue(':fecha_actualizacion', $nuevafecha, PDO::PARAM_STR);
        $sentencia->bindValue(':consecutivo', $consecutivo, PDO::PARAM_STR);
        $sentencia->bindValue(':mes', $mes, PDO::PARAM_STR);
        $sentencia->bindValue(':ruta', $destino, PDO::PARAM_STR);

        $array = array("ALUMBRADO", "CATASTRO","COMPRAS");
        $count = count($array);

        for ($i = 0; $i < $count; $i++) {

            $sentencia->bindValue(':departamento', $array[$i] , PDO::PARAM_INT);
            $sentencia->execute();

        }        

         /* Aplicamos los Cambios en La BD */
        $bd->commit();
        header('Location: http://plataforma.mx');
        mail("$email1,$email2", "nuevo correo", "mensaje","FROM: [email protected]");    

        }
        catch (Exception $e) {
             /* Cancelamos La Transacción por si exista Error*/
            $mbd->rollBack();
            echo "Se Presento Un Error :  " . $e->getMessage();
        }

    }

I hope you can help me!

    
asked by Sharly Infinitywars 22.06.2017 в 20:55
source

1 answer

1

Put the redirect after sending the mail and you should use the PHPMailer to send mail.

mail("$email1,$email2", "nuevo correo", "mensaje","FROM: [email protected]");    
header('Location: http://plataforma.mx');
    
answered by 24.06.2017 / 06:49
source