在php邮件中包含整个页面

Is it possible to include a separate html page in a php email?

Example, create a separate page that has all the content on it I want to email it and then include it in a php mail() on another page as the message?

Thanks

If you meant sending HTML email, yes. You can do that. You just need to add additional headers in the fourth parameter of mail() and pull the information from the HTML file you have using file_get_contents(). Please check this:

http://css-tricks.com/sending-nice-html-email-with-php/

Yes, it's possible exactly how rationalboss explained. Personally I use PEAR for html emails. It's a pain to get started with if you're not familiar to PEAR, but life has improved once I got it going.

Careful though, html/css does not have the same support in email clients that it does in browsers. You can create a beautiful page and find out that most people receive it with huge glitches due to certain CSS rules being ignored.

Best practice last I heard is to keep it simple and use inline styles for everything. Avoid floats and positioning. In fact, I believe it is actually still safer to use tables when dealing with email layouts if you need things to sit next to each other.

And then test in as many email clients as you can. Then cry and try to fix things.

I hear good things about Email on Acid for testing. It's a pay service but they offer a limited test for 3 clients as well.

If you're just doing a relatively simple email then it shouldn't be too bad. But if you're trying to make something that really looks great I recommend doing some googling on styling html specifically for emails.