How can I send a bootstrap table by email in php without losing format?

1

I am trying to generate a report, I recover my data from the database and I form a table with it, I want to output it by means of an email in php

mail($to,"Reportex","",$headers);

The problem is the bootstrap format is lost.

here the code:

$correos ="Bcc: [email protected]\r\n";
    $headers = "From: remitente>\r\n";
    $headers .= $correos;
    $headers .= "MIME-Version: 1.0\r\n";
    $boundary = uniqid("HTMLEMAIL");
    $headers .= "Content-Type: multipart/alternative;".
                "boundary = $boundary\r\n\r\n"; 
    $headers .= "This is a MIME encoded message.\r\n\r\n"; 
    $headers .= "--$boundary\r\n".
                "Content-Type: text/plain; charset=utf-8\r\n".
                "Content-Transfer-Encoding: base64\r\n\r\n"; 
    $headers .= chunk_split(base64_encode(strip_tags($content)));
    $headers .= "--$boundary\r\n".
                "Content-Type: text/html; charset=utf-8\r\n".
                "Content-Transfer-Encoding: base64\r\n\r\n"; 
    $headers .= chunk_split(base64_encode($content));
    mail($correos,"Reporte Seguimiento Productividad: ".$fecha1,"",$headers);
    
asked by joseyanez91 18.08.2017 в 19:52
source

1 answer

1

1 .- In the mail header, your variable headers , did you add the attribute Content-Type ?

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

2 .- How are you referencing bootstrap in the code of your mail? From a public resource that can be accessed from anywhere:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">

Or just put the relative path of your server

<link rel="stylesheet" href="../css/bootstrap.min.css">

This may affect the file will be downloaded to view the mail in the team of the person who opens the mail, if the resource is not published publicly it will not find it and will not show the style you want.

    
answered by 18.08.2017 / 20:06
source