Reputation: 137
I'm trying to setup PHPMailer to send e-mails that consist mostly from PHP generated HTML (i.e dynamic tables made with data from a database, inside functions and even different classes). However most examples I've seen only have this method for adding content to the email body:
$mail->Body = $body;
which seems easy to implement for simple content and/or strings but not dynamic PHP content.
Is there some kind of way of adding content to the e-mail body by chunks or perhaps an entire PHP page? It seems like a really stupid question but I can't quite find a way to do it...
Upvotes: 0
Views: 760
Reputation: 112
You can generate the content and put it in to a buffer string, then, you can set the body of PHPMailer with this.
Here an example:
ob_start();
// Include a file here or insert the code that generate the HTML
// Example
include('page.php');
$body = ob_get_contents();
ob_end_clean();
$mail->Body = $body;
Upvotes: 1