Hayles Posted November 9, 2009 Share Posted November 9, 2009 I want to send an email that includes an existing page. For instance when the email sends, I want the content of newsletter.php to be inside the email (so the recipient can see this page on their email). I can do this in asp, and want to know if it can be done in php, so i can quit using asp. I really hope I'm making sense here Quote Link to comment https://forums.phpfreaks.com/topic/180811-sending-a-html-page-through-email/ Share on other sites More sharing options...
MadTechie Posted November 9, 2009 Share Posted November 9, 2009 Yes you can do it, the part saying "includes an existing page." it kinda strange, but lets say you want you send a HTML email, and your newsletter was newsletter.php, here's a big start (I used Example #4 from mail as a basis), <?php // multiple recipients $to = 'recp1@example.com' . ', '; // note the comma $to .= 'recp2@example.com'; // subject $subject = 'News Letter'; $message = 'Hello below is the newsletter<br>'; //cheating -- okay what this does it loads up newsletter.php but // captures it into a variable instead of outputting it ob_start(); include "newsletter.php"; // message $message .= ob_get_clean(); // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Example Newsletter <Newsletter@example.com>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> untested but you should get the idea Quote Link to comment https://forums.phpfreaks.com/topic/180811-sending-a-html-page-through-email/#findComment-953895 Share on other sites More sharing options...
Hayles Posted November 9, 2009 Author Share Posted November 9, 2009 Thanks heaps for this, it seems to be working perfectly much appreciated!! Quote Link to comment https://forums.phpfreaks.com/topic/180811-sending-a-html-page-through-email/#findComment-954433 Share on other sites More sharing options...
MadTechie Posted November 9, 2009 Share Posted November 9, 2009 Yay okay if this is solved please click topic solved (bottom left) Note: you can unsolve it if needed! Quote Link to comment https://forums.phpfreaks.com/topic/180811-sending-a-html-page-through-email/#findComment-954441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.