Re: mail() php in message
| From: | Onno Kuipers | Date: | Sun, 12 Oct 2003 20:47:25 +0000 |
| Subject: | Re: mail() php in message | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165921@lists.php.net to get a copy of this message | ||
Matthias Wulkow wrote:
Hallo Onno,
am Sonntag, 12. Oktober 2003 um 20:07 hast Du Folgendes gekritzelt:
OK> Hi,
OK> is there a way to create a mail (with the mail() function) that contains OK> php in the message.
OK> Like:
OK> <?php
OK> $to = "user@domain.com";
OK> $subject = "a subject";
OK> $message = ????
OK> I WANT TO PUT SOME PHP IN HERE TO CREATE A TABLE IN THE MESSAGE:
OK> $columnbooks = mysql_list_fields($dbname,tmp,$mysql_link);
OK> $sqlbooks = "select isbn,books.title, writer, publisher from tmp,books OK> where tmp.user=books.user";
OK> $resultbooks = mysql_db_query($dbname,$sqlbooks);
?>>
OK> <table cellpadding="2" cellspacing="2" border="1" style="text-align: left; width: 100%;">>
OK> <?php
OK> while ($valuebooks = mysql_fetch_array($resultbooks))
OK> { print "<tr bgcolor=#ccf504>";
OK> for($i=0; $i< 4; $i++ )
OK> {
OK> $gebruikerbooks=$valuebooks[$i];
OK> print "<td> $gebruikerbooks </td>";
OK> }
OK> print "</tr>";
OK> }
OK> mysql_free_result($resultbooks);
OK> THIS SHOULD BE THE END OF THE MESSAGE
OK> HERE I WILL DO THE MAILING
OK> mail($to,$subject,$message);
?>>
You should know that php runs on a server, not on the client machine. So what do you want to
do with php-code in a mail? You could put html (generated by php for
example), so that the mail-reader can display a table.
That is exactly what I want to do. I've got a mysql database. I want to generate a table with data from the database into the message of the mail. I know how the to put html in the message:
$message = '
<html>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
but I want to know how to put html generated by php in the message.