php - Mailing from Flash (using Actionscript 3.0)
Get the solution ↓↓↓Solution:
Use a pure ActionScript SMTP mailer, such as:
http://www.bytearray.org/wp-content/projects/smtpmailer/SMTPMailer%200.6.zip
Library and FLA example included within the ZIP.
Example implementation:
import org.smtp.mailer.SMTPMailer;
import org.smtp.encoding.JPEGEncoder;
import org.smtp.encoding.PNGEnc;
import org.smtp.events.SMTPEvent;
import flash.utils.ByteArray;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.*;
// create the socket connection to any SMTP socket
// use your ISP SMTP
var myMailer:SMTPMailer = new SMTPMailer (smtp_txt.text, 25);
// register events
// event dispatched when mail is successfully sent
myMailer.addEventListener(SMTPEvent.MAIL_SENT, onMailSent);
// event dispatched when mail could not be sent
myMailer.addEventListener(SMTPEvent.MAIL_ERROR, onMailError);
// event dispatched when SMTPMailer successfully connected to the SMTP server
myMailer.addEventListener(SMTPEvent.CONNECTED, onConnected);
// event dispatched when SMTP server disconnected the client for different reasons
myMailer.addEventListener(SMTPEvent.DISCONNECTED, onDisconnected);
// event dispatched when the client has authenticated successfully
myMailer.addEventListener(SMTPEvent.AUTHENTICATED, onAuthSuccess);
// event dispatched when the client could not authenticate
myMailer.addEventListener(SMTPEvent.BAD_SEQUENCE, onAuthFailed);
// take the snapshot
var myBitmap:BitmapData = new BitmapData ( stage.stageWidth, stage.stageHeight );
// encode as JPEG with quality 100
var myEncoder = new JPEGEncoder( 100 );
send_btn.addEventListener (MouseEvent.CLICK, onClick);
message_txt.text = "<img src='http://www.google.com/images/logo_sm.gif'</img><br><b>Picture file attached!</b>";
function onClick ( pEvt:MouseEvent )
{
// replace this by any DisplayObject
myBitmap.draw ( this );
var myCapStream:ByteArray = myEncoder.encode ( myBitmap );
// sends HTML email
//myMailer.sendHTMLMail ( from_txt.text, to_txt.text, subject_txt.text, "<img src='http://www.google.com/images/logo_sm.gif'</img><br><b>Picture from HTML :)</b>");
// send HTML email with picture file attached
myMailer.sendAttachedMail ( from_txt.text, to_txt.text, subject_txt.text, message_txt.text, myCapStream, "image.jpg");
}
function onAuthFailed ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Authentication Error";
}
function onAuthSuccess ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Authentication OK !";
}
function onConnected ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Connected : \n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}
function onMailSent ( pEvt:SMTPEvent )
{
// when data available, read it
status_txt.htmlText = "Mail sent :\n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}
function onMailError ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Error :\n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}
function onDisconnected ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "User disconnected :\n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}
function socketErrorHandler ( pEvt:IOErrorEvent )
{
// when data available, read it
status_txt.htmlText = "Connection error !";
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: port 80 in use by "unable to open process" with pid 4!
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.