I'm trying the personalize email content using HTML Mime Mail Class by Richard Heyes at
This class is written in PHP and PHP code is inserted into the page to create the message.
Does anyone know how to include form variables and table variables in the email to be processed by the class?
Considering that you emailed me, i thought i'd post my response here too....
<edited a bit>
Now, normally I wouldnt answer such a question since i dont have knowledge specific to the question, but I will attempt to give you an answer from a logical guess.
Now, when you submit a form to a php script, if you had <input name="asdf" type="text"> , then the variable $asdf, would automagically be available to use.. however, when you have functions, they can only access variables inside them unless you global them, in this case, putting a
inside the function should make the variable accessible. BUT, here, its not just a function, so it MIGHT NOT work either, in which case you can try to put the global line in the class , near the top somewhere (after the class brackets have opened). As a final choice, you could modify the constructor of the class (i hope you understand how object oriented programming works) and pass the variables you need as parameters to the constructor.
SitePoint Community Advisor
myPHPhost.com: PHP is our game
In the example given there is a variable called $html, well to personalise the message you would modify this variable: e.g. Your form sent a variable called $name
As you can see from the example to add an image you do the following:
$html = '<HTML><BODY BACKGROUND="background.gif">'."\r\n".'<FONT FACE="Verdana, Arial" COLOR="#FF0000">'."\r\n".'Hello '.$name.' how are you today.</FONT>'."\r\n".'<P></BODY></HTML>';
$filename = 'yourimage.gif';
$image = fread($fp = fopen($filename, 'r'), filesize($filename));
note that you must change the image/gif to the appropriate mime type for the image format used.
$mail->add_html_image($image, 'yourimage.gif', 'image/gif');
If you need any more help then I will see if I can come up with a clearer example.
Karl: when the value in $HTML is sent to the mail client, the variable is lost. The same thing would happen with images if not for the code required that you stated. Mabye the same type of thing is required for a variable but I don't know what it would be. Any ideas?
The example given with the Class is very good and should realyl provide you with everything you need to create a working system combined with my snippet of customising the HTML output.
Karl: Your right. The example you provided works! I had the syntax wrong. Can you explain what it does?
'."\r\n".'Hello '.$name.' how are you today.</FONT>'."\r\n".'
Also: Do you know how to extend the 30 second time limit for class.html.mime.mail.inc? If the page takes more than 30 seconds to process, the class times out with a error.
I all it does is includes the $name variable in the HTML, the ' stops the string, .$name adds the value of the name variable to the string, .' starts the text string again.
\r\n = newline of text.
The time limit:
set_time_limit(60) would give the script 60 seconds to execute.