twan twan - 1 year ago 78
CSS Question

Sending an entire html page with phpmailer

I purchased an email template and customized it to what I want, but now I'm stuck on how to send it.

The template file is an entire html page with included fonts and even a stylesheet at the top (styletags actually, not an attached file) with mediaqueries and some font settings.

Do I send all of that? Including header tags and more? It's basically an entire html page.

How part of my emailscript is build now:

$texts = 'html template';

But I haven't tested my own code yet because the template file is full of single quotes and double quotes. So the variable doesn't like that, I tried replacing all single quotes to double quotes in the templatestring but then my fonts are not working anymore (I tested remotely using this site:

Answer Source

PHPMailer itself doesn't do anything special with HTML content (though msgHTML reads your content to make a rough plain-text version). It sounds like you're just having trouble quoting inline content. You might like to try a different form of quoting called nowdoc which will tolerate all kinds of quotes without a problem:

$texts = <<<'EOT'
html template

You could also save it in an external file and read it in when you need it, which also avoids quoting issues:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download