mail form


Build a Mail Form with Flash and PHP

Dear Reader;

The content of this tutorial is out of date. Flash (and the underlying ActionScript language) has moved on. I have, regrettably, not moved on with it.

Flash is currently a great deal more capable, but also much more complex, than it was when I wrote this tutorial.

I have kept this content online because I still get mail from readers who have found it useful. While I am very pleased by this, I want to make it clear that this material can no longer be considered “best practice,” and I can no longer offer support.

If you can use it, you are welcome to it. The code has been tested and refined thanks to input of many generous readers. I offer it as is.


This tutorial will demonstrate how to build a Flash movie which will, with some help from PHP, send an email message. This tutorial uses Macromedia Flash MX (not MX 2004, although updated project files are available for Flash MX 2004).


Here’s a demo of what we’ll be building in this tutorial. It’s perfectly safe to play with — I’m not harvesting email addresses or anything sinister like that, so feel free to experiment with your own address. The send mail function is disabled but otherwise it is fully featured, including the validation routine. Try clicking the “send” button with some fields empty. Try leaving out the “at” symbol from your email address. Try deliberately typing a fraudulent email address. Refresh your browser page to reset the form.


There are advantages to replacing simple html “mailto:” links with a form which enables your site’s visitors to send you an email.

Project file downloads for Flash MX and Flash MX 2004 are available at the end of page five.

There are some excellent resources on the internet which demonstrate how to create a form in html whose “action” calls a cgi or PHP script. One I can recommend from first hand experience is Kuckus’ Contact Page, which uses PHP.

Obviously if you have a site that is predominately or entirely built in Flash it is undesirable to have to go out to a html page to provide an email form. It turns out not to be very hard to build the equivalent of a mail form in Flash MX. Although Flash supports “mailto:” links, Flash by itself isn’t capable of actually sending mail. Fortunately PHP does have this capability and even more fortunately Flash and PHP communicate with each other exceptionally smoothly.


This tutorial contains very little original material by me. Rather, it is a synthesis that seeks to combine what I feel are the best elements of several authors’ works into one optimized package. The three major sources I need to acknowledge are:


This tutorial will examine the PHP and Flash elements separately.
Page Two covers building the PHP processEmail.php server script.
Page Three covers creating the graphics and text fields for the Flash module
Page Four covers the ActionScript that ties everything together.
Page Five concludes with two nice User Interface refinements. (Links to project file downloads for Flash MX and Flash MX 2004 are also available at the end of page five.)
Page Six covers expanding your form, enabling it to send additional text input

divider ornament