Jump to content

Recommended Posts

Of course it's possible:

<?php

$to = "[email protected]";
$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.

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

let me explain:

<?php
$to = "[email protected]"; // 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.

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

 

if (!empty ($_POST)){

 

     $email['sender'] = '[email protected]';

     $email['recipient'] = '[email protected]';

 

     $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);

 

}

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 = "[email protected]";
$from = '[email protected]'; //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);
?>

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.