JuanFernandoz
JuanFernandoz

Reputation: 799

Php buffer output, css and mail

Currently I have a script that send some mail, the script result are a couple html tables:

$from = "prueba.com <[email protected]>"; 
$to = "[email protected]"; 
echo "<div>"; 

$contenido = ob_get_contents(); 
echo "</div>"; 
$cabeceras = "Content-type: text/html; charset=iso-8859-1 \r\n" 
           ."MIME-Version: 1.0 \r\n" 
           ."To: $cliente <$email> \r\n" 
           ."From: prueba <[email protected]> \r\n"; 

mail($to,$subject,$contenido,$cabeceras); 

ob_end_flush(); 

As might give css to that email? as I have tried several methods and none has worked.

Thanks in advance for your cooperation

EDIT:

THIS is my CODE http://www.mediafire.com/?bq9352xh6paji1d

Upvotes: 3

Views: 769

Answers (2)

Mihai Iorga
Mihai Iorga

Reputation: 39724

Maybe you wanted like this: (using ob_get_clean())

ob_start();
echo "<div>"; 
    // more html
echo "</div>";
$contenido = ob_get_clean(); 

and lose the last ob_end_flush();

TEST:

$from = "prueba.com <[email protected]>"; 
$to = "[email protected]"; 
ob_start();
echo "<div>"; 
echo "<table border='1'><tr><td>TEST</td></tr></tr>";
echo "</div>";
$contenido = ob_get_clean(); 

$cabeceras = "Content-type: text/html; charset=iso-8859-1 \r\n" 
           ."MIME-Version: 1.0 \r\n" 
           ."To: $cliente <$email> \r\n" 
           ."From: prueba <[email protected]> \r\n"; 

mail($to,$subject,$contenido,$cabeceras); 

Upvotes: 3

Gianpaolo Di Nino
Gianpaolo Di Nino

Reputation: 1147

You might take a read here: http://css-tricks.com/sending-nice-html-email-with-php/

Upvotes: 0

Related Questions