Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to send dynamic page email?

Status
Not open for further replies.

alan123

MIS
Joined
Oct 17, 2002
Messages
149
Location
US
I tried to send email from php script, I want to display dynamic data in html format on the browser, meanwhile send email using this dynamic page.
Now the question is I have to manually copy and paste html code to "message" field in mail function, how to let program automatic "capture" html code and insert to message field?
Anyone can help me? thanks in advance.

 
I don't understand what you mean by "send email by the dynamic page." A PHP script can send mail -- a dynamic web page is nothing more than the output of a PHP script.

It is the PHP script that produces the HTML for display that should be sending the email.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
What I mean is how to send output of a php script to email receipient? Thanks.
 
Instead of directly outputting the page, put the HTML in a variable.

Print the variable to send it to the browser.

Email the content of the variable/


As an aside, are you aware of the PHPMailer email-sending class? It can make sending compex emails easier.
Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I know I can put html in a variable, actually it contains the data generated by oracle, the test code like this:
Code:
<?php
....
$message="<html><body><table><tr><td>Name</td><td>Age</td></tr>";
while(ora_fetch($cursor)){
$name=ora_getcolumn($cursor,0);
$age=ora_getcolumn($cursor,1);

$message .= "<tr><td>$name</td><td>$age</td></tr>";

}



  $semi_rand = md5(time());
  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
  
  
  $headers .= "\nMIME-Version: 1.0\n" .
              "Content-Type: multipart/mixed;\n" .
              " boundary=\"{$mime_boundary}\"";

  $message = "This is a multi-part message in MIME format.\n\n" .
             "--{$mime_boundary}\n" .
             "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
             "Content-Transfer-Encoding: 7bit\n\n" .
             $message . "\n\n";

 
  $data = chunk_split(base64_encode($data));


  $message .= "--{$mime_boundary}\n" .
              "Content-Type: {$fileatt_type};\n" .
              " name=\"{$fileatt_name}\"\n" .
              //"Content-Disposition: attachment;\n" .
              //" filename=\"{$fileatt_name}\"\n" .
              "Content-Transfer-Encoding: base64\n\n" .
              $data . "\n\n" .
              "--{$mime_boundary}--\n";
}

$message = StripSlashes($message);
  
 

/* and now mail it */
mail($to, $subject, $message, $headers);

but it doesn't send mail correctly, any clue?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top