BEFORE SEND MESSAGE
1) FIRST SOVLE SMTP PROBLEM
SMTP AUTHENTICATION EXCEPTION IN VB
2) IMAP ENABLED
3) CORRECT GMAIL ADDRESS IN CODE
4) CORRECT THIS GMAIL PASSWORD IN CODE
------------------------------------------------------------------------------------------------------------------
READ MORE:
------------------------------------------------------------------------------------------------------------------
4) CORRECT THIS GMAIL PASSWORD IN CODE
------------------------------------------------------------------------------------------------------------------
READ MORE:
------------------------------------------------------------------------------------------------------------------
CONTACT FORM WITH FILE ATTACHMENT AS3 PHP - YouTube
https://www.youtube.com/watch?v=IZLdFZ71t3w
5 hours ago - Uploaded by SAVE MONEY
CONTACT FORM WITH FILE ATTACHMENT AS3 PHP ... PHP Contact Form and Form Validation ...
https://www.youtube.com/watch?v=IZLdFZ71t3w
5 hours ago - Uploaded by SAVE MONEY
CONTACT FORM WITH FILE ATTACHMENT AS3 PHP ... PHP Contact Form and Form Validation ...USEFUL IMAGES:
https://www.google.com/settings/security/lesssecureapps
https://mail.google.com/mail/u/0/#settings/fwdandpop
------------------------------------------------------------------------------------------------------------------
STEPS:
OPEN ACTION SCRIPT AS3
IMPORT FORM IMAGE TO STAGE AND LOCKED LAYER
MAKE LAYER 2
USE LAYER 2 AND DRAW FOUR INPUT TEXT BOXES WITH INSTANCE NAMES
name_txt, mail_txt, msg_txt, pathFile
USE LAYER 2 AND DROP TWO BUTTON FROM COMPONENTS
WITH INSTANCE NAMES
selectFile_btn, sendAll_btn
ON MAN TIME LINE SET CLASS NAME ContactFormAttachment
SAVE YOUR FLA AND CLASS FILE IN SAME FOLDER
REMOVE THESE LINE IN ContactFormAttachment.as FOR MAKE OWN BUTTON
sendAll_btn.label = "SENT"
sendAll_btn.enabled = false;
--------------------------------------------------------------------------------------------------------------ContactFormAttachment.as CODE
--------------------------------------------------------------------------------------------------------------
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.DataEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.net.FileReference;
import flash.net.URLLoader;
public class ContactFormAttachment
extends Sprite {
private var request:URLRequest ;
private var fileRef:FileReference;
/**
* Constructor
*/
public function ContactFormAttachment() {
// New File Reference
istance, adding all the listeners
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadComplete);
// Button Click
events
selectFile_btn.addEventListener(MouseEvent.CLICK, openDialog)
sendAll_btn.addEventListener(MouseEvent.CLICK, sendAll)
}
/**
* Open the browser
file window
*/
private function openDialog(event:MouseEvent):void{
fileRef.browse();
}
/**
* Dispatched when the
user selects a file for upload or download from the file-browsing dialog box.
*/
private function selectHandler(event:Event):void{
// Get file info
var file:FileReference = FileReference(event.target);
// check if file <
50kb
if (file.size < 50000) {
// The PHP Script to
call
request = new URLRequest("https://fbigadgets.000webhostapp.com/ContactFormAttach.php");
// Set variables to
send
request.method = URLRequestMethod.POST;
request.data = new URLVariables();
request.data.mail_txt = mail_txt.text;
request.data.name_txt = name_txt.text;
request.data.msg_txt = msg_txt.text;
// Display File
information (name + size)
pathFile.text = file.name + "
(" + file.size + "
Kb)"
} else {
// File >= 50kb
pathFile.text = "File size must be < 50kb"
}
}
/**
* Submit the form
* Invoked after submit
button click event
*/
private function sendAll(event:MouseEvent):void{
// If email is not
valid we stop the submit
if (!isEmailValid(mail_txt.text)) {
mail_txt.text = "Email is not valid";
return;
}
/*
* 'request' property
will be 'null' if a file is not yet selected and the form shouldn't be sent
*
* NOTE: in a real
scenario you should allow to send a form without a file selection
* and you should
manage this form in a different way, avoid using FileReference
*/
if (request != null) {
// Submit form
uploading the selected file
fileRef.upload(request);
} else {
// Display a msg if
any file is selected
pathFile.text = "Please select a file from your HD (with size
< 50kb)";
}
}
/**
* Dispatched periodically
during the file upload or download operation
* NOTE: it's useful to
get the upload progress percentage)
*/
private function progressHandler(event:ProgressEvent):void {
// Display upload
file progress
pathFile.text = int((event.bytesLoaded / event.bytesTotal)* 100) + "%"
}
/**
* Dispatched when
download is complete or when upload generates an HTTP status code of 200.
*/
private function completeHandler(event:Event):void {
pathFile.text = "Loading Complete"
}
/**
* Dispatched after
data is received from the server after a successful upload.
*/
private function uploadComplete(e:DataEvent):void {
var mailResponse:Object = e.data
// Email sent with
success
if (mailResponse == "1") {
// Change SUBMIT
button status to disable
sendAll_btn.label = "SENT"
sendAll_btn.enabled = false;
// Reset form fields
mail_txt.text = "";
name_txt.text = "";
msg_txt.text = "";
// Set to null the
request object
request = null
} else {
pathFile.text = "There are some server side issue";
}
}
/**
* CHECK EMAIL VALID
* Return TRUE = Email
valid | FALSE = Email Wrong
*/
private function isEmailValid(mail:String):Boolean {
var emailRegEx:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
if (!emailRegEx.test(mail)) {
return false
} else
return true;
}
}
}
-----------------------------------------------------------------------
OR CHANGE CLASS FILE FOR FRAME ACTION SCRIPT USE
------------------------------------------------------------------------
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.DataEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.net.FileReference;
import flash.net.URLLoader;
var request:URLRequest ;
var fileRef:FileReference;
fileRef = new FileReference();
selectFile_btn.addEventListener(MouseEvent.CLICK,
openDialog)
function openDialog(event:MouseEvent):void{
fileRef.browse();
}
fileRef.addEventListener(Event.SELECT,
selectHandler);
function
selectHandler(event:Event):void{
var
file:FileReference = FileReference(event.target);
if
(file.size < 50000) {
request = new
URLRequest("https://fbigadgets.000webhostapp.com/ContactFormAttach.php");
request.method =
URLRequestMethod.POST;
request.data =
new URLVariables();
request.data.mail_txt
= mail_txt.text;
request.data.name_txt
= name_txt.text;
request.data.msg_txt
= msg_txt.text;
pathFile.text =
file.name + " (" + file.size + "
Kb)"
}
else {
pathFile.text =
"File size must be < 50kb"
}
}
sendAll_btn.addEventListener(MouseEvent.CLICK,
sendAll)
function sendAll(event:MouseEvent):void{
if (!isEmailValid(mail_txt.text)) {
mail_txt.text
= "Email is not valid";
return;
}
if (request != null) {
fileRef.upload(request);
} else {
pathFile.text
= "Please select a file from your HD (with size < 50kb)";
}
}
function isEmailValid(mail:String):Boolean {
var emailRegEx:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
if (!emailRegEx.test(mail)) {
return false
} else
return true;
}
fileRef.addEventListener(ProgressEvent.PROGRESS,
progressHandler);
function
progressHandler(event:ProgressEvent):void {
pathFile.text =
int((event.bytesLoaded / event.bytesTotal)* 100)
+ "%"
}
fileRef.addEventListener(Event.COMPLETE,
completeHandler);
function
completeHandler(event:Event):void {
pathFile.text =
"Loading Complete"
}
fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,
uploadComplete);
function
uploadComplete(e:DataEvent):void {
var mailResponse:Object
= e.data
if (mailResponse ==
"1") {
mail_txt.text =
"";
name_txt.text =
"";
msg_txt.text =
"";
request = null
} else {
pathFile.text =
"There are some server side issue";
}
}
--------------------------------------------------------------------------------------------------------------
HOW TO WRITE PRIVATE VAR REMOVE IN CLASS
--------------------------------------------------------------------------------------------------------------
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.DataEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.net.FileReference;
import flash.net.URLLoader;
public class ContactFormAttachment extends Sprite {
public function ContactFormAttachment() {
// OR PASTE HERE ALL CLASS CODE
// CONSTRUCTOR CODE MEAN YOUR ACTION SCRIPT LIKE BELOW CODE
var request:URLRequest ;
var fileRef:FileReference;
fileRef.addEventListener(Event.SELECT, selectHandler);
function selectHandler(event:Event):void{
var file:FileReference = FileReference(event.target);
if (file.size < 50000) {
request = new URLRequest("https://fbigadgets.000webhostapp.com/ContactFormAttach.php");
request.method = URLRequestMethod.POST;
request.data = new URLVariables();
request.data.mail_txt = mail_txt.text;
request.data.name_txt = name_txt.text;
request.data.msg_txt = msg_txt.text;
pathFile.text = file.name + " (" + file.size + " Kb)"
} else {
pathFile.text = "File size must be < 50kb"
}
}
}
}
}
MUST BE LOG IN ACCOUNT 000WEBHOSTING FOR RUN PHP FILE
USE 000WEBHOSTING
UPLOAD PHP
FILE IN public_html
FOLDER
ContactFormAttach.php CODE--------------------------------------------------------------------------------------------------------------
<?php
header("Cache-Control: no-cache,
must-revalidate");
// Mime Creation
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$tmp_name = $_FILES['Filedata']['tmp_name'];
$type = $_FILES['Filedata']['type'];
$name = $_FILES['Filedata']['name'];
$size = $_FILES['Filedata']['size'];
// if the upload
succeeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure
that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name))
{
// open the file for
a binary read
$file = fopen($tmp_name,'rb');
// read the file
content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it
and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
}
$headers = "From:".$_REQUEST[email_txt]."\r\n" . "MIME-Version:
1.0\r\n" . "Content-Type:
multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\"";
$subject = "ActionScript 3.0
- Form attachment\n";
$message.= "ActionScript 3.0 - Form
attachment\n";
$message.= "---------------------------------------------\n";
$message.= "SENDER INFORMATION:\n";
$message.= "\nMail: ".$_REQUEST[mail_txt]."\n";
$message.= "\nName: ".$_REQUEST[name_txt]."\n";
$message.= "---------------------------------------------\n";
$message.= "\nMessage: ".$_REQUEST[msg_txt]."\n";
$message = "This is a
multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:
text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding:
7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Transfer-Encoding:
base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
if (@mail($_REQUEST[mail_txt], $subject, ($message), $headers)){
// Return 1 if
everything is ok and mail is sent
echo "1";
}
else {
// Return 0 if there
are problems while sending mail
echo "0";
}
?>
EmoticonEmoticon