1

I have a string with an .eml message. How to render this email on the page of my site in some kind of frame?

Is there any composer extension, that could render .eml content as a regular mail app.

D.R.
  • 2,540
  • 3
  • 24
  • 49
  • @JeremyHarris what should I try? I have a simple string with content of an `.eml` mesaage. I need to display it as regular mail app renders it on the page of my site. Simple `echo $mail` won't help here. – D.R. Dec 21 '16 at 16:15
  • 5
    Possible duplicate of [How to parse a .eml file in php?](http://stackoverflow.com/questions/11409235/how-to-parse-a-eml-file-in-php) – Jeremy Harris Dec 21 '16 at 16:16
  • @JeremyHarris thank you, but no. I need to **render**, not to *parse*. I just don't know what to search. Maybe I could use ` – D.R. Dec 21 '16 at 16:19
  • 2
    You mean render it raw? You could just `echo(file_get_contents('test.eml'));` and spit out the file contents if thats all you wanted. If you want it formatted, you need to parse it first, THEN build the HTML/CSS around your data from the email. No silver bullet here I am afraid. – Jeremy Harris Dec 21 '16 at 16:21
  • @JeremyHarris thank you for your answer. I was looking exact for a "silver bullet" (composer module/extension), that could take raw `.eml` message with headers and so on and give me HTML/CSS output. – D.R. Dec 21 '16 at 16:24

1 Answers1

1

I used this extension

And snippet like this:

$parser = new PhpMimeMailParser\Parser();
$parser->setText($message);

$html = $parser->getMessageBody('html');

echo $html;

$html is wrapped in my view into proper <div>'s.

D.R.
  • 2,540
  • 3
  • 24
  • 49