# Send HTML email with dynamic content from flash

**URL:** <https://forum.kirupa.com/t/send-html-email-with-dynamic-content-from-flash/273679>\
**Category:** flash\
**Created:** [October 18, 2008, 8:45pm UTC](https://forum.kirupa.com/t/send-html-email-with-dynamic-content-from-flash/273679 "2008-10-18T20:45:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronenronen](https://avatars.discourse-cdn.com/v4/letter/r/e47c2d/32.png) [@ronenronen](https://forum.kirupa.com/u/ronenronen)\
**Post date:** [October 18, 2008, 8:45pm UTC](https://forum.kirupa.com/t/send-html-email-with-dynamic-content-from-flash/273679/1 "2008-10-18T20:45:19Z")

</div>

I created a flash photo gallery with thumbs. When you click a thumb the matching big pic is opened with a “tell a friend” button next to it. Pressing the button opens a form where the user enters his and his friend’s names and email addresses, and then sends an e-mail to the friend. I made it like this: flash sends vars from form to a php file; php file allocates the names and addresses to the “$to”/"$from" fields, allocates an HTML content to the “$message” field (because I need to include an \<img src\> tag to include the pic in the created email), and sends the email using mail() function. The result: the email is received successfully.

To summarize, the php is built like this:

```auto
<?php
//receiving variables from Flash, through POST object, and storing them in local php variables
$name=$_POST['name'];
$email=$_POST['email'];
$emailfriend=$_POST['emailfriend'];
//define the receiver of the email
$to=$emailfriend;
//define the subject of the email
$subject = 'from your friend';
// message
$message = '
<html>
 <head>
  <title>example</title>
 </head>
 
 <body leftmargin="0" topmargin="0" 
  <div id="content">
     <div id="emailContent">
     <br>
     Hi <b>***</b>,<br><br>
     <b>***</b> e-mailed from the web site.
     <br><br><br>
     <br><br>
          <img src="[example.png](http://www.fornarina.com/data/assets/images/BLAZE_8410J84527.png)" border="0" alt="" align="texttop"/>
          <br><br>
        </div>
     </div>
 </body>
</html>
';
$headers = "From: $name <$email>
";
$headers .= 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
//send the email
mail($to, $subject, $message, $headers);
?>

```

My problem is, I want the email to be created **dynamically** : I want the created email to include the names of the user and his friend, and to include the image that the user wants to tell about, dynamically.

Anyone can help??
