Jump to content


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


insert contenst of php page into body of email

Recommended Posts

is there anyway i can insert the contents of a php page into the body of an email?

can someone post a simple example. Need to basically scrape a page and insert the page contents into the body section of an email that's being sent via php.

Share this post

Link to post
Share on other sites
Hi, how are you planning in getting the page in the first place? Is it a page you are getting from the net or one you are generating in the first place? The second is a lot easier than the first.

Share this post

Link to post
Share on other sites
//name your file either through root path or whatever
$filename = "your_php_file_name_here.php";
//open the file
$file = fopen($file, "r");
//get the php file's size
$filesize = filesize($filename);
//read the file and put contents into a variable
$code = fread($file, $filesize);
//then you can take your code variable and put it into your mail form

<form method="post" action="mailer_script_filename.php">
Message:<textarea rows="20" cols="25" name="newmsg">
<?php echo $code; ?>
<br />
<input type="submit" value="send email">


i'm not sure, but if your mailer script gets parse errors then just do

$code = addslashes($code);

but it probably won't, so disregard that last little snippet unless you get errors

Share this post

Link to post
Share on other sites


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.