DarkPrince2005 Posted November 12, 2007 Share Posted November 12, 2007 Is it possible to send an entire web page to an email using mailto:person@blah.com function, with what has been typed in the text boxes. And if so what would the code look like Quote Link to comment Share on other sites More sharing options...
aschk Posted November 12, 2007 Share Posted November 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
DarkPrince2005 Posted November 12, 2007 Author Share Posted November 12, 2007 Jeez that seems complicated. Quote Link to comment Share on other sites More sharing options...
Dragen Posted November 12, 2007 Share Posted November 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
DarkPrince2005 Posted November 15, 2007 Author Share Posted November 15, 2007 ok that works, but it is sending me the code, how do i make it send me the form data? Quote Link to comment Share on other sites More sharing options...
axiom82 Posted November 15, 2007 Share Posted November 15, 2007 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); } Quote Link to comment Share on other sites More sharing options...
Dragen Posted November 15, 2007 Share Posted November 15, 2007 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); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.