Step-by-step installing
This is a tutorial that shows how to install the Contact Form with Mail Attachments component.
Contact Form with Mail Attachments is a Flash, actionscript 3, mail contact form component that suppports multiple mail attachments. The server side script is in php.
Customize globals.php
Set here the server details that match your identity.
- $TO : Set this to be the email address to which the message will be sent (likely your email)
- $SUBJECT : Set here the subject of the mail (sent to the $TO address); <NAME> will be replaced by code with the name of the sender (filled in the ‘Your Name’ field of the form)
- $CONFIRMATION_SUBJECT : The subject of the confirmation mail (the confirmation mail will be sent to the mail address of the sender: filled in the ‘Your Email’ field of the form)
- $CONFIRMATION_MESSAGE : Set in this variable the body of the confirmation mail (the confirmation mail will be sent to the mail address of the sender: filled in the ‘Your Email’ field of the form, it confirms that his mail was successfully sent; it also contains a copy of his original message)
- $CONFIRMATION_NAME : Set here your name; will appear in the header of the mail in front of $CONFIRMATION_MAIL (John Doe [mail@example.com])
- $CONFIRMATION_MAIL : Set this to be your mail (will apprea near your name: John Doe [mail@example.com])
Install the scripts
- Inside the directory where you want to install your app, create a subdirectory ’scripts’. Make the directory permissions 775: rwx-rwx-r-x (this is because flash player will directly access the scripts and php will need r-w permissions here: creates directories and stores uploaded files, then deletes them after the email is sent)
- Copy all the php scripts inside this newly created directory. Make each file’s permissions 644: rw–r—r–
Install the flash files
- Inside the directory where you want to install the contact form, outside the ’scripts’ directory (you don’t need to install where the scripts directory is, you can install anywhere as the paths to the scripts can be configured in contact.xml file): copy all the necessary files – contact.swf, AC_RunActiveContent.js, contact.html and data directory
- Make sure that the files have 644 permissions, data directory should have 755, and contact.xml from inside data directory should also be 644
Customize data/contact.xml file
- Open data/contact.xml file in a text editor (notepad will do great, don’t use a word processor like MS Word)
- Inside this file, the <php> tag must be edited to reflect the real script paths: <mailscript> tag, set it’s path attribute to be the path to the ’sendmail.php’ script; <upload_script> tag, set it’s path attribute to be the path to the ‘upload_file.php’ script – these paths can be relative or absolute;
For example:
<php>
<mailscript path="scripts/sendmail.php" />
<upload_script path="scripts/upload_file.php" />
</php>
This assumes that the ’scripts’ directory is in the same directory as ‘contact.swf’ file
- Everything else in the xml file is optional, meaning it can be left as it is
- <title> : The Title that appears at the top of the contact form
- <yourname>, <yourmail>, <message> : <caption> – ‘optional’ attribute specifies whether the current field is optional or required when validating the form: valid values “true” – meaning optional, “false” – meaning required; The text inside the <caption> tag is the text that will appear next to the corresponding text field;
<text> – ‘default’ attribute sets the default text that appears inside the corresponding input text field; when this textfield receives focus, this text will be cleared; ‘clearOnClose’ attribute specifies whether the text inputted will be cleared when the form is closed or not: valid values “true” – meaning the text will be cleared, “false” – the text will remain uncleared, so that when the form is reopened, the last text inputted in this filed it’s still there
- <error>: <messages> – sets the error messages when the form is not filled correctly
- <yourname>, <yourmail> and <message>: ‘empty’ attribute – this error will be displayed when the input textfield is empty and the textfield has been declared as required (see previous point)
- <yourmail>: ‘notValidated’ attribute – this error appears when the email entered in the <yourmail> tag is not a valid email address
- <close>: if ‘visible’ attribute on <button> tag is ‘true’, the close button is visible, if it’s ‘false’, it’s not visible
- <submit>: <event> : ‘closeFormUponSubmit’ – valid values: ‘true’ – meaning the form will be closed if the form is successfully submitted, ‘false’ the form will not be closed
- <files> : <upload_file> : ‘max_file_size’ set this the maximum allowed file size in KiloBytes; if the file is bigger than this value, the file will not be added to upload list
- <file_filter>: ‘type’ attribute – Set the type of files allowed by this filter; accepts wildcards (*): to allow mp3 files ‘*.mp3′; to allow more types by one filter: ‘*.mp3;*.wav’; ‘description’ attribute – Sets the description associated with this filter; These filters work based on file extensions!
To set file attributes in terminal:
chmod UGO file
Where UGO is the file perrmission: U – user permission (owner)
G – group permission
O – others permission (public)
1 – execute
2 – write
4 – read
Example: 644 – U=2+4=write+read
G=4=read
O=4=read


hello, is there a way to make a script which sends images as attachments in emails, using an image that is loaded into my flash xml gallery? in other words, the file is already on the server, i dont need to upload files.
thanks
aaron
Hi,
yes sure. then the script would be much easier, since the upload is not needed anymore. then only a sendmail script would be used and the contents of the attachment image taken right from disk. Actually the purpose of the upload is that sendmail script needs the contents of the image, but it can only access the image from a web server.
Regards,
Ovidiu
Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language
See you!
Your, Raiul Baztepo
@RaiulBaztepo
Hi Raiul,
This post is a tutorial on how to install and properly configure the Contact Form with Mail Attachments v1.1 found here
Sorry if it was missleading.
Regards,
Ovidiu
Hi there I purchased your contact_form2.0 and for some reason its not sending attachment to my email. Please Help!!! I need to get this working ASAP.
Hi,
I need some more details from you in order to be able to help you. What’s your hosting server operating system: unix or windows? Do you receive the mail, but without the attachments? What’s the size of the file you’re trying to attach in the mail?
Thanks,
Ovidiu
I am attempting to load the Contact form in another movie in the 4th level when a button is pushed. I am getting the following error;
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at pinosh.contactForm::ContactForm/init()
at pinosh.contactForm::ContactForm()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
Can you suggest a fix?
Thanks,
Ken
Hi Ken,
Here is what you should do to avoid that error:
in ContactForm.as, in ContactForm method find the last line, that says this.init(); and comment it out.
Then write this line, just below the line you commented out: this.addEventListener(Event.ADDED_TO_STAGE, this.init);
One more step is needed: right below, find the line private function init():void and change it to
private function init(event:Event):void
Let me know if you still have problems with it.
Ovidiu
@admin
Thanks Ovidiu.
I managed to eliminate the error by changing this line in the init function from stage to parent:
this.stage.addEventListener(MouseEvent.MOUSE_UP, this.stopScroll);
the stage was the null object causing the error.
It’s a timing issue and your fix also works.
Thank you very much for answering my question.
Ken
Hello Ovidiu,
I bought the contact form from http://www.flashcomponents.net (the one in AS3) but i have some problems using it. I have to specify that i’m not so good using AS3. I imported the form in another MC using this syntax:
var mailformLoader:Loader = new Loader();
var mailformUrlReq:URLRequest = new URLRequest(”contact.swf”);
mailformLoader.load(mailformUrlReq);
contents.questions.contact_mc.addChild(mailformLoader);
The problem is that the forms are inaccessible. I can’t click or insert text in any of the input texts. Buttons are like disabled too. I made the changes you specified to the file ContactForm too.
Note:
1. there is no other MC over the form that disables the mouseEnable=true(by default);
2. i tried to import it on the stage too but same problems.
can u help me please? is prety urgent
Tnx
Actually can you give me a hand with the steps i need to perform in order to import the contact form correctly into another SWF ?
Hi,
The code you’re using to load the contact form is ok.
Please check however that none of the parent movieclips have mouseEnabled or mouseChildren turned to false in code.
Also make sure there is nothing above the containing movieclip that could block mouse input from reaching to the form.
Also, the form works ok as a standalone? Make sure you can input text in the form without loading it in first.
And make sure you made the changes to ContactForm.as as in this comment: http://www.ovidiudiac.ro/blog/2009/03/step-by-step-installing/#comment-46
If you still can’t make it to work, please send me a private mail with a link where I can replicate this problem.
Here’s what i did step by step:
1. I made the exact changes as in the comment below.
2. Imported the swf with the code i showed you first.
It seems to be working now… i can access buttons and textFields. First problem is solved. Didn’t figure out what it was but i used a project’s backup file and everything worked.
A new problem still persists:
TypeError: Error #1009: Impossible to access to a propriety or method of a null object reference.
at pinosh.contactForm::ContactForm/::init()
at pinosh.contactForm::ContactForm$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
at contact_fla::MainTimeline$iinit()
Damn my head blows . . .
After you did the exact changes as in the comment, did you recompile contact.fla?
Make sure you commented out the line this.init(); in ContactForm method.
OMG :O
Thank you for your time
Everything’s ok now… Can’t believe i’ve been so blind XD . . . it’s hard to be a noob XD !
I’m glad you figured it out.
Can the Contact Form w/ Attachments be retro-fitted for AS 2.0? My site is written for that and I’d like to keep it that way. Please advise. Thanks.
Yes sure it can.
However I wouldn’t recommend it since it would be a lot of work involved.
Unless you really need to include/load the contact form into an as2 project, you can do with it just as it is right now.
Hi, i just purchased your flash application, installed it, and all works well until i upload an image and hit send. I get a frozen screen showing the progress percentage stuck at 0%. Please help for i love the app and really need this to work for me.
Thanks a bunch!
Forgot to mention in detail – when i use the form without attaching a file, everything works perfectly. It’s just when i attached a file i run into problems.
Hi,
If only upload does not work, then it looks like the upload script is somehow not accessible, or your php installation doesn’t allow the upload.
Firstly make sure you followed the installation guide exactly (on this page and on Contact Form – Changes from v1.1 to v1.2).
If you still face the problem, it would help a great deal if you could give me a link to your site so i can reproduce the problem.
Ovidiu
FREAKIN FANTASTIC!! Thanks so much for this, really!
One last thing – How would I set this so that “Message” is not required? Ideally, I’d like to make attaching a file a requirement along with name and email.
To set the “Message” to be optional, in the “data” folder open the “contact.xml” file in a text editor (notepad is perfect) and find the lines:
<message>
<caption optional=”false”>Message*:</caption>
And change them to:
<message>
<caption optional=”true”>Message*:</caption>
Also you can find in this file option like this for name and email.
To make attaching a file a requirement, you need to edit some actionscript code. If you edit the code then you need to recompile the flash file. For that, you need FLASH CS3 at least.
Open the ContactForm.as (classes/pinosh/contactForm/ContactForm.as) file in a text editor (notepad will do fine):
locat the validateForm function; scroll to the end of the function; add the following lines of code just before this line this.error_.text = “”;
if(this.attachedFilesContainerModel.FilesAttached == null || this.attachedFilesContainerModel.FilesAttached.length == 0)
{
this.error_.text = “You must attach at least one file!;
return false;
}
You can change the error message to whatever you want.
After adding these lines, you must recompile the flash file.
That should be all.
Ovidiu
All i can say is you are very good at what you do, and extremely clear in your instructions. I’m happy people like yourself exist.
Thanks again for all of your help,
Chacon,
You’re very welcome and thank you for the kind words.
I have a question for you but I’d prefer to hit you on a private email if that’s ok with you.
Sure it’s ok.
Hello, i don’t have your email address.
You can respond directly to chacon@helen-marie.com or on this thread. So:
I have all up and running…except! I get the confirmation email but there’s no attachment. Instead i’m getting a long string of crazy code. However, the sender’s confirmation email has the attachment.
Thanks in advance for your help with this one.
Hi,
You can always get my email from About page. That’s not important anyway.
Your problem however is strange, because the 2 emails are sent in the same way. Did you change anything in the php code? What email client are you using? You read the 2 emails with the same client, and the confirmation mail is ok but the other one is not?
Ovidiu
I’m using mac mail. Which php file and code are you referring to?
…my email client is fine. Here’s the problem – the sender gets
the confirmation which I assume is working fine. Its the contents
of the mail that is out of whack. Plus, when I (the admin) gets a sender
confirmation, there’s no attachment, just lots of code.
Nice work.
Do you also provide FLA file and configuration documentation?
Regards!
The fla and source code including php is available in download package.
Documentation is in this post and this one: http://www.ovidiudiac.ro/blog/2009/03/contact-form-changes-from-v11-to-v12/
Also a small help file about the xml configuration is available.
Everything is pretty straight forward, but if you find yourself in trouble you can ask for help here.
Best
10.99 $ for a single licence for my freelance website (translator)
and I buy you one : P
Hi
Please goto my website (’http:/www.pizzapal.co.uk’), it needs a contacts page and an orders page in that sequence…I used Flash CS3 for the buttons and Dreamweaver mx 2004 for the frameset, all of which were created using a P.C running a Windows Vista Business O.S and my server is .net. Can you help with the components that I can author into the sites aesthetic? Mark Poole
Feel free to email…
Hi Pinosh,
I am a man who works with Limou… We still have some problems with the program…
The program is running on a linux server but the message “message not sent” apprears whatever I do.
I work on the v1.2 of the program.
I don’t understand anything about php (I program only with Actionscript 3) so I don’t match to find the mistake.
Do you have a new idea or a process to find where is the bug ?
here you will find the file online : http://www.isor.fr/formulaires/directeurdexploitation/contact.html
Thank you for your help.
lemathurin
Hi Aubin,
This is a bug in php for windows, which is said to be fixed in php version 5.3.1 – the point is that updating to the latest php version, you should get away of this problem.
Here is the php bug: http://bugs.php.net/bug.php?id=28038
If upgrading php is not option, let me know and we should be able to provide you a workaround to this matter.
Best regards!
Hi Pinosh,
Unfortunatly, my server doesn’t work under PHP version 5.3.1… So I have to find an other solution for my problem.
Do you have any idea to solve it ?
Thank you for your help
Regards
Please help !!
Can you show me a live link where you’re testing it so I could do some checks?
You can send me an email.
hello Pinosh
i am trying to get it work but i am not receiving any attachment in my mail.
Contact form is showing the progress like everything is OK but then i do not find the file attached.
I did everything as explained and I checked 5 times
this is the link to my test page
http://www.brunoisakovic.com/contactme/contact.html
i would appreciate any help.
Bruno
Hey,
I just tried to send an email from your website and the message was not sent.
I looked at the http requests and noticed that the php mailer script is not found: 404 Not Found.
http://www.brunoisakovic.com/contactme/scripts/sendmail.php – try it
Ovidiu
Hello,
I am getting this errors and after reading and re- reading the code i could’t find the mistake:
• Warning: 3596: Duplicate variable definition. SOURCE: var tween1 : Tween = new Tween(this.caption_, “x”, Regular.easeOut, this.caption_.x, 1, 0.6, true);
• Warning: 3596: Duplicate variable definition. SOURCE: var tween2 : Tween = new Tween(this.delete_, “x”, Regular.easeOut, this.delete_.x, -this.delete_.width, 0.6, true);
• Warning: 3596: Duplicate variable definition. SOURCE: var transform : ColorTransform = this.dragScroll.transform.colorTransform;
can you please help me. I appreciate it.
THANX
Hi Ovidiu,
Here is my problem, I bought your AS contact form with attachment function, I added a textfield to it and I get the following errors:
• Warning: 3596: Duplicate variable definition.
I get this for three lines:
67. private var mailIsOptional_:Boolean;
68. private var phoneIsOptional_:Boolean;
833. var transform : ColorTransform = his.dragScroll.transform.colorTransform;
I don’t know if is because of that that the message cannot be sent. Please help!!! I’m stuck with this and cannot seem to get it right
File location: http://webfactorystudio.com/violin/Link/Valuation/attach01.html
Thanks in advance for your help
Hi,
As you can see, those are not errors, but warnings – meaning you can do with with the warnings and your app will run just fine.
Those warnings tell you that those variables (tween1, tween2, transform) were already defined in the same scope. The quick fix would be to rename’em – maybe tween2.. and remember to update references as well.
Cheers
Hi,
Your message doesn’t get sent because it can’t find the php script: http://webfactorystudio.com/violin/Link/Valuation/scripts/sendmail.php
Make sure you configured the paths correctly.
Check with a http monitor to make sure that your scripts are reached.