Jump to content

Sending entire web page to Email


DarkPrince2005

Recommended Posts

Of course it's possible:

<?php

$to = "theemail@address.com";
$subject = "whole page";
$message = file_get_contents("htmlpage.html");

mail($to,$subject,$message);

?>

 

You'll probably want to be setting the content headers for the mail function to html, but there's nothing different to a normal mail function call.

 

If i'm missing something here (i.e. not understanding your requirements) let me know.

Link to comment
Share on other sites

complicated? that's probably the simplest send mail script I've seen in php ;)

let me explain:

<?php
$to = "theemail@address.com"; // this is the variable that simply hold the email address to send the email to.
$subject = "whole page"; // this is the subject of thet email
$message = file_get_contents("htmlpage.html"); // file_get_contents collect the data from whatever url you put between the brackets

mail($to,$subject,$message); // then mailto sends the email. the first var is the recipient, second is the subject and third is the message, which happens to be the webpage.
?>

 

sorry if that was very basic, but.. well. It is.

Link to comment
Share on other sites

You need to execute the mail() function from within the form page.

 

if (!empty ($_POST)){

 

     $email['sender'] = 'you@email.com';

     $email['recipient'] = 'them@email.com';

 

     $subject = 'Subject';

 

     $message = "Dear {$_POST['recipient_name']}, bla bla bla.";

 

     $headers  = "From: Sender Name <{$email['sender']}>\r\n";

     $headers .= "Reply-To: <{$email['sender']}>\r\n";

     $headers .= "Return-Path: <{$email['sender']}>\r\n";

     $headers .= "X-Sender: <{$email['sender']}>\r\n";

     $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";

     $headers .= "X-Priority: 1\r\n";

     $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";

 

     mail ($email['recipient'], $subject, $message, $headers);

 

}

Link to comment
Share on other sites

You need to execute the mail() function from within the form page.

No you don't. You just need to execute it from whatever page the form is sent to.

 

You're codes pretty spot on though.. not sure what a couple of things do, but I haven't dealt with mailto too much:

X-Sender
and
X-Mailer

 

but to simplyfy it a bit:

<?php
$to = "theemail@address.com";
$from = 'myemail@address.com'; //your own email address so they can reply.

$subject = "whole page";

$headers  = "From: $from <{$from}>\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; //this is what makes it display the html properly

$message = file_get_contents("htmlpage.html");

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

Link to comment
Share on other sites

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.