Displaying contents of processed PHP page as body in E-Mail

the mail() function

Moderators: egami, macek, gesf

Post Reply
gbfar
New php-forum User
New php-forum User
Posts: 24
Joined: Tue Aug 16, 2005 10:40 am

Tue Aug 16, 2005 10:47 am

Hello guys,

:help:

I do need help. I had been looking for something where I could find how to attach a processed PHP page into the body part of the email but couldn't find one. I have a PHP page which displays the results of a certain query. I wish to include that whole PHP page (including images on that page) into the mail. Is it possible that when the email is sent it processes the page before actually including it or it has to be generated before it could be included?

Already thanks!

gb

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Tue Aug 16, 2005 1:12 pm

ob_start() ob_clean() ob_get_content() are your best friends in that case
learn more at php.net
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

gbfar
New php-forum User
New php-forum User
Posts: 24
Joined: Tue Aug 16, 2005 10:40 am

Thu Aug 18, 2005 7:04 am

Thanks Guys!

I actually was able to send the whole page. All I did was to open that file with fopen while passing the variable into it and it worked out perfectly. Here is the code-

Code: Select all

<?php
   $e_mail_subject = "something";
   
   $handle = fopen ("http://www.someabsolutefilename?variablename=$variablevalue", "r");
   while (!feof ($handle)) {
      $buffer = fgets($handle, 4096);
      $reply .= $buffer;
   }
   fclose ($handle);

   $mime_boundary = "<<<--GB--" . rand(10000,32000) . "-" . rand(10000,32000) . "--BG-->>>";
   
   $headers .= "From: $call_employee <$call_emp_email>\r\n";
   $headers .= "To: $v_call_contact <$v_call_email>\r\n";
   $headers .= "Bcc: $call_employee <$call_emp_email>, AnotherOne <another email>\r\n";

   $headers .= "MIME-Version: 1.0\r\n";
   $headers .= "Content-Type: multipart/mixed;\r\n";
   $headers .= " boundary=\"".$mime_boundary."\"";

   $message .= "This is a multi-part message in MIME format.\r\n";
   $message .= "\r\n";
   $message .= "--".$mime_boundary."\r\n";

   $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
   $message .= "Content-Transfer-Encoding: 7bit\r\n";
   $message .= "\r\n";

   $message .= $reply;

   $message .= "\r\n";
   $message .= "--".$mime_boundary."\r\n";

?>

And that's it, using the simple mail() function of PHP it went on!!!

Enjoy!

GB

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Thu Aug 18, 2005 10:45 am

Please use the code tags when posting the code.. youtr post has been edited..
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests