Jump to content

Sending a html page through email...?


Hayles

Recommended Posts

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  :confused:

Link to comment
https://forums.phpfreaks.com/topic/180811-sending-a-html-page-through-email/
Share on other sites

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  = '[email protected]' . ', '; // note the comma
$to .= '[email protected]';

// 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 <[email protected]>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

 

untested but you should get the idea

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.