Jump to content

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  = '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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.