This is a sample code to send email attachments for airxmail(actionscript 3 smtp/pop3 library).

Requirements:
Flex SDK 3.4 or more
AIR 1.5 or more
airxmail library ( download )

related links:
Basic usage of airxmail
How to send html mail.

sample code

use MimeBinaryPart ( application/octet-stream )

basic usage
var contentType:ContentType = ContentType.MULTIPART_MIXED;
var mimeMsg:MimeMessage = new MimeMessage(contentType);
:
:
var filePart:MimeBinaryPart = new MimeBinaryPart();
filePart.setAttachementFile(File.desktopDirectory.resolvePath("image.jpg"),"attachemnt-image.jpg");
mimeMsg.addChildPart(filePart);

sender.send(mimeMsg);
sender.close();
how to change content-type
var filePart:MimeBinaryPart = new MimeBinaryPart()
filePart.contentType.setMainType("image");
filePart.contentType.setSubType("jpeg");

Note: MimeImagePart is image/xxxx part.

filePart:MimeImagePart = new MimeImagePart();
filePart.setAttachementFile(file,"attachemnt-image.jpg");   // --> image/jpeg
//filePart.setAttachementFile(file,"attachemnt-image.gif");   // --> image/gif

Related Posts

36 Responses to “actionscript 3 : how to send email attachements ( use airxmail library)”

  • free games より:

    I found this is an informative and interesting post so i think so it is very useful and knowledgeable. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing ability has inspired me. Really the article is spreading its wings rapidly.

  • Dave より:

    This is really cool, thanks for making it!

  • yimogod より:

    Really thanks for this. And i have a question:
    How to send one email with both plain text and attachments?

  • parishon より:

    Hi,
    I send a tsl email with attachment with a gmail account,
    and the question is when the attachment is very small,it can send,
    but when the attachment is about bigger than 40KB,it can’t,and got
    this message “GOT ALERT! type=22”
    can you help?

  • coltware より:

    Please use revision 66 or more. (coltware_airxmail_air2_r66.swc)
    I fixed this problem.

  • parishon より:

    hi,coltware
    I use SecureSocket to instead of the tlsSocket,the alert message is not appear,
    but the size of the attachment is still not work good,when i send with a 40k or bigger attachment,i can’t receiver any email from the software,i send a email for more detail

  • DELL より:

    Hi,
    I am getting the message…
    GOT ALERT! type=10

    Here is the code…
    import com.coltware.airxmail.ContentType;
    import com.coltware.airxmail.INetAddress;
    import com.coltware.airxmail.MailSender.SMTPSender;
    import com.coltware.airxmail.MimeMessage;
    import com.coltware.airxmail.MimeTextPart;
    import com.coltware.airxmail.RecipientType;
    import com.coltware.airxmail.smtp.SMTPClient;
    import com.coltware.airxmail.smtp.SMTPEvent;
    import com.hurlant.crypto.tls.TLSConfig;
    import com.hurlant.crypto.tls.TLSEngine;
    import com.hurlant.crypto.tls.TLSSocket;

    import flashx.textLayout.factory.TruncationOptions;

    import mx.logging.Log;
    import mx.logging.LogEventLevel;
    import mx.logging.targets.TraceTarget;

    [Embed(source=”/certs/server.crt”,mimeType=”application/octet-stream”)]
    public var myCert:Class;
    [Embed(source=”/certs/server.key”,mimeType=”application/octet-stream”)]
    public var myKey:Class;

    private var sender:SMTPSender;
    private function initApp():void
    {
    init();
    testMail();
    }
    private function init():void
    {
    var logTarget:TraceTarget = new TraceTarget();
    logTarget.filters = [“*”];
    logTarget.includeCategory = Boolean(LogEventLevel.DEBUG);
    Log.addTarget(logTarget);
    }
    private function testMail():void
    {
    sender = new SMTPSender();
    sender.setParameter(SMTPSender.HOST,”mymailserver”);
    sender.setParameter(SMTPSender.PORT, 25);
    sender.setParameter(SMTPSender.CONNECTION_TIMEOUT, 5000);
    sender.setParameter(SMTPSender.AUTH,true);
    sender.setParameter(SMTPSender.MYHOSTNAME, “localhost”);
    sender.setParameter(SMTPSender.ENABLE_BUFFER, true);
    sender.setParameter(SMTPSender.USERNAME,”email@myserver”);
    sender.setParameter(SMTPSender.PASSWORD,”mypassword”);

    sender.addEventListener(SMTPEvent.SMTP_AUTH_NG, clbSMTPAuthNg);
    sender.addEventListener(SMTPEvent.SMTP_AUTH_OK, clbSMTPAuthOK);
    sender.addEventListener(SMTPEvent.SMTP_ACCEPT_DATA, clbSMTPAcceptData);
    sender.addEventListener(SMTPEvent.SMTP_COMMAND_ERROR, clbCommandError);
    sender.addEventListener(SMTPEvent.SMTP_CONNECTION_FAILED, clbConnFailed);
    sender.addEventListener(SMTPEvent.SMTP_NOOP_OK, clbNoopOK);
    sender.addEventListener(SMTPEvent.SMTP_NOT_SUPPORT_ESMTP, clbNoSupportESMTP);
    sender.addEventListener(SMTPEvent.SMTP_SENT_OK, clbSMTPOK);
    sender.addEventListener(SMTPEvent.SMTP_START_TLS, clbStartTLS);

    //var tlssocket:TLSSocket = new TLSSocket(“mymailserver”, 675);
    //sender.setParameter(SMTPSender.SOCKET_OBJECT,tlssocket);
    //sender.setParameter(SMTPSender.SOCKET_OBJECT, new TLSSocket());

    // Create email message
    var message:MimeMessage = new MimeMessage();

    // Set from email address and reciepients
    var from:INetAddress = new INetAddress(“myemailid”,”from label”);
    message.setFrom(from);

    var toRecpt:INetAddress = new INetAddress(“emailaddress1″,”to label”);
    message.addRcpt(RecipientType.TO,toRecpt);

    //
    message.setSubject(“Hi This is me”);
    message.setTextBody(“This is a test mail app!! \r\n this is first email from the app.”);

    sender.send(message);
    sender.close();
    }
    private function clbSMTPAuthNg(event:SMTPEvent):void
    {
    trace(“Authorization negative.”);
    }
    private function clbSMTPAuthOK(event:SMTPEvent):void
    {
    trace(“Authorization Okay.”);
    }
    private function clbSMTPAcceptData(event:SMTPEvent):void
    {
    trace(“SMTP data accepted.”);
    }
    private function clbCommandError(event:SMTPEvent):void
    {
    trace(“Command error.”);
    }
    private function clbConnFailed(event:SMTPEvent):void
    {
    trace(“Connection failed.”);
    }
    private function clbNoopOK(event:SMTPEvent):void
    {
    trace(“No operation okay.”);
    }
    private function clbNoSupportESMTP(event:SMTPEvent):void
    {
    trace(“ESMTP not supported.”);
    }
    private function clbSMTPOK(event:SMTPEvent):void
    {
    trace(“SMTP sent okay.”);
    }
    private function clbStartTLS(event:SMTPEvent):void
    {
    trace(“TLS started.”);
    var sock:Socket = event.socket as Socket;
    var conf:TLSConfig = new TLSConfig(TLSEngine.CLIENT);
    conf.ignoreCommonNameMismatch = true;
    conf.trustSelfSignedCertificates = true;
    //conf.trustAllCertificates = true;
    var cert:ByteArray = new myCert;
    var key:ByteArray = new myKey;
    conf.setPEMCertificate(cert.readUTFBytes(cert.length), key.readUTFBytes(key.length));
    var tls:TLSSocket = new TLSSocket();
    //tls.setTLSConfig(conf);
    sender.setParameter(SMTPSender.SOCKET_OBJECT, tls);
    tls.startTLS(sock, “mymailserver”, conf);
    }

  • DELL より:

    This is the actual output…

    [Sys conf: flex 4+AIR]

    [SWF] MMApp.swf – 2,750,841 bytes after decompression
    com.coltware.airxmail.MimeBodyPart create part object : [CD5D756C-E395-4A11-CF07-38E9A05C4192][object MimeMessage]
    com.coltware.airxmail.MailSender.SMTPSender [start] msg send
    com.coltware.airxmail.MailSender.SMTPSender connect …
    com.coltware.core.SocketJobSync connect invoked xxx.xxxx.xxx(25)
    com.coltware.core.JobSync addJob + [object Object]
    com.coltware.airxmail.smtp.SMTPClient enable auth : xxxxxx.xxxxxx@xxxx.com
    com.coltware.core.JobSync addJob + [object Object]
    com.coltware.core.JobSync addJob + [object Object]
    com.coltware.core.JobSync addJob + [object Object]
    com.coltware.core.JobSync addJob + [object Object]
    com.coltware.core.JobSync addJob + [object Object]
    com.coltware.airxmail.MailSender.SMTPSender close()..
    com.coltware.core.JobSync addJob + [object Object]
    com.coltware.core.SocketJobSync mail.xxxx.com connected
    com.coltware.airxmail.smtp.SMTPClient set timeout [5000]
    com.coltware.airxmail.smtp.SMTPClient no ready…
    com.coltware.airxmail.smtp.SMTPClient [SMTP]220-xxxxxxx.xxxx.xxx ESMTP Exim 4.69 #1 Fri, 18 Feb 2011 18:35:11 +0530
    220-We do not authorize the use of this system to transport unsolicited,
    220 and/or bulk e-mail.
    com.coltware.core.JobSync prepared accept job ….
    com.coltware.core.JobSync job size is [7]
    com.coltware.airxmail.smtp.SMTPClient EHLO localhost
    com.coltware.airxmail.smtp.SMTPClient [EHLO]:250-xxxxxxx.xxxx.xxx Hello localhost [xxx.xxx.xxx.xxx]
    com.coltware.airxmail.smtp.SMTPClient [EHLO]:250-SIZE 52428800
    com.coltware.airxmail.smtp.SMTPClient [EHLO]:250-PIPELINING
    com.coltware.airxmail.smtp.SMTPClient [EHLO]:250-AUTH PLAIN LOGIN
    com.coltware.airxmail.smtp.SMTPClient need auth : 250-AUTH PLAIN LOGIN

    com.coltware.airxmail.smtp.SMTPClient [EHLO]:250-STARTTLS
    com.coltware.airxmail.smtp.SMTPClient [EHLO]:250 HELP
    com.coltware.core.JobSync commit job :[10]
    com.coltware.airxmail.smtp.SMTPClient [AUTH]:334 xxxxxxxxxxxx
    com.coltware.core.JobSync commit job :[9]
    com.coltware.airxmail.smtp.SMTPClient [USERNAME]:334 xxxxxxxxxxxx
    com.coltware.core.JobSync commit job :[8]
    com.coltware.airxmail.smtp.SMTPClient [PASSWORD]:235 Authentication succeeded
    com.coltware.core.JobSync commit job :[7]
    com.coltware.airxmail.smtp.SMTPClient STARTTLS
    com.coltware.airxmail.smtp.SMTPClient SMTP AUTH OK
    Authorization Okay.
    com.coltware.airxmail.smtp.SMTPClient [STARTTLS]:220 TLS go ahead
    com.coltware.airxmail.smtp.SMTPClient starttls…
    TLS started.
    com.coltware.airxmail.MailSender.SMTPSender set socket object [object TLSSocket]
    com.coltware.core.JobSync commit job :[9]
    Type 2 method: 28ms
    GOT ALERT! type=10
    com.coltware.core.SocketJobSync socket closed from server true
    [Unload SWF] MMApp.swf

  • coltware より:

    Thank you DELL and I am so sorry to reply lately.

    That is very difficult for me.

    I think the code raise error.

    >tls.startTLS(sock, “mymailserver”, conf);

    accoding The TLSEngine code(r5 ver1.3),
    GOT ALERT type=10
    means tsl communication error.

    http://code.google.com/p/as3crypto/source/browse/trunk/as3crypto/src/com/hurlant/crypto/tls/TLSEngine.as?r=5
    Line 702:
    ———————————————————————-
    private function parseAlert(p:ByteArray):void {
    //throw new Error(“Alert not implemented.”);
    // 7.2
    trace(“GOT ALERT! type=”+p[1]);
    close();
    }
    ———————————————————————-

    I don’t know TLS protocol in detail.
    But I checked the TLSEngine code and TLS protocol as I can.
    I hope the following memo help you.

    “TLS Alert Registry” and “TLS Alert Registry” on
    http://www.iana.org/assignments/tls-parameters/tls-parameters.xml

    The current TLSEngine source code revision was r28.
    Log message was
    ————————————————————————–

    In this commit:

    Added: SSL 3.0 Support for the TLSocket/TLSEngine.

    Modified: The TLSEngine over all to support ISecurityParameters/IConnectionState
    in keeping with SSL 3.0/TLS 1.0.

    Added: A patch to TLSConfig, and relevant changes to TLSEngine to support the
    following trust parameters:
    ignoreCommonNameMismatch : Ignores a condition where the server’s name
    as connected via the socket doesn’t match the common name in the cert.
    trustSelfSignedCertificates : Should be self-explanatory.
    trustAllCertificates : Again, self-explanatory.

    Added: PKCS9 ASN.1 type “unstructuredName”. I ran into this on VMWare
    ESX/Virtual Center servers.
    Added: Support for at least responding to a TLS “CertificateRequest” handshake
    message from a server. If this message is received, the client responds with a
    “null cert” and keeps going. It doesn’t yet support providing a client
    cert(still working on that).

    Added: An event change to pop-out to ask the user if they want to accept a given
    cert or not. The cert is included in event that pops out of TLSSocket. See
    TLSSocket/TLSSocketEvent.

    Modified: TLSEngine, modified all over the place. I changed a few things,
    encapsulated a few other things.

    Modified: Patched the Base64 encoder/decoder with a path from Steve Webster’s
    Base64 page here: http://dynamicflash.com/goodies/base64/

    This fixed THIS problem: http://skitch.com/sh0rtwave/bt4u7/flex-debugging-
    kodiak-src-simpletester.mxml-adobe-flex-builder-3

  • DELL より:

    Thanks buddy for your precious response.

    The library works perfectly alright with GMAIL and others.

    I have checked the mail server error. According to my mail server error log, the certificate not found…something like this error. I think this may be a certificate issue and my mail server may not rely on self-signed certificate. I am not sure.

    Anyway, your precious support will certainly give me some direction. I’ll notify you whenever I’ll solve the issue.

    Thanks,
    DELL

  • coltware より:

    Hi DELL

    I am glad to hear it.

    The trouble gave a good chance to check about TLS/SSL for me.
    But I am sorry I can not help you.

    I am waiting your good news.

  • Frank より:

    Hi,

    I am using coltware.airxmail to send emails from my Flex app.

    I would like to send VCalendar appointment files generated from Flex straight to Outlook so they are opened in the Calender view. I am able to send the VCal files as an attachment on an email, however, these are not “auto-opened” in Outlook Calendar, which requires the user to double click on the file.

    I have been trying to set the content type of the mail to “text/x-vCalendar”, and pass in a byte array containing the VCal file, however, no joy. The vCal arrives as a .txt attachment to an empty email!

    I wonder if anyone has had previous experience with this kit, or can suggest any pointers?

    Or even suggest another component they have used to send VCal files straight to outlook, from ActionScript?

    Here’s my sample code (DEMO CODE VERY MESSY JUST TO GET POINT ACROSS):

    var sender:SMTPSender = new SMTPSender();
    // Set the from / to / host / port values here

    var contentType:ContentType = new ContentType();

    contentType.setMainType(“text/x-vCalendar”);

    var message:MimeMessage = new MimeMessage(contentType,”UTF-8″);

    var file:File = File.desktopDirectory.resolvePath(“vcal.vcs”);

    file.addEventListener(Event.COMPLETE, function(ev:Event):void {

    message.addRawContent(file.data);
    sender.send(message);
    sender.close();

    });
    file.load();

  • coltware より:

    Hi frank.
    Thank you for using my airxmail library.

    I made the sample code.
    But the content type is NOT text/x-vCalendar.
    But I can open the scheduled item.

    —– sample code —–

    var message:MimeMessage = new MimeMessage(ContentType.MULTIPART_MIXED);

    message.setSubject(“new vcal event”);
    message.setFrom(from);
    message.addRcpt(RecipientType.TO,toAddr);

    message.setTextBody(“this is vCalendar mail”);

    //
    // add attachement file as vcs file
    //
    var vcsPart:MimeBinaryPart = new MimeBinaryPart();
    vcsPart.transferEncoding = “7bit”;
    vcsPart.contentType.setParameter(“name”,”event.vcs”);
    vcsPart.contentDisposition.setParameter(“filename”,”event.vcs”);
    vcsPart.setAttachementFile(File.desktopDirectory.resolvePath(“event.vcs”));
    message.addChildPart(vcsPart);

    sender.send(message);
    sender.close();

  • Frank より:

    Hi Coltware,

    Thank you so much for providing the code example, however, it’s not quite what I was looking for.

    The example above sends the file as an email attachment, so the user must double click on the attachment for it to be added to Outlook Calendar.

    Is there any way for the Coltware Mail to send the VCS file straight to Outlook Calendar? So the appointment opens when the email is received?

    Thank you again for your help
    Frank

  • coltware より:

    Hi frank.

    >Is there any way for the Coltware Mail to send the VCS file straight to Outlook Calendar? So the appointment opens when the email is received?

    Is it possible without MS Exchange server ?
    Airxmail is a library to make mime message and smtp.

    So I want to see the mime messsage code ( email body text )
    Is it possible to send me the email you want to make using outlook.

    Or
    Do you have any information to send the email using another language(Java, Perl, C# etc.. ) or library ?

    Maybe it takes a few days to reply because of big earthquake in japan.

    Regards

  • Sagar より:

    Hi,

    I want to get latest 10 messages using pop. But not sure how to do this. Can

    u suggest?

    private function result_uidl(e:POP3ListEvent):void{
    for(var i:int=e.length-1; i>=0; i–){
    // e.client.retr(e.getNumber(i),e.getValue(i));

    if(i>e.length-10)
    {
    //e.reverseList();

    e.client.retr(e.getNumber(i),e.getValue(i));

    }

    }

    e.client.quit();
    }

    I tried this , i got 10 messages but not the latest 10. How to get it?

  • Zayd より:

    Hi Coltware

    Is there any way to monitor the progress of sending a mail?

    E.g. when attaching files – how could I use a ProgressEvent to monitor how much of the mail has been sent so far?

    Thanks

    Zayd

  • coltware より:

    Hi zayd.

    There is no way so far.
    But I have a plan to make ProgresEvent for that.
    I replied e-mail for details.

    Regards

  • Jay より:

    Hi. Coltware.

    Thank you so much for providing the code example.
    I’ve got a error message in Flash CS5.5.
    * error message :
    The definition of base class socketJobSync was not found.
    Method marked override must override another method.

    SocketJobSync file is not library folder.
    I don’t know using library. please help me.

    Regards

  • coltware より:

    Hi jay

    SocketJobSync class is in airxlib project.
    Airxlib is my air commons classes for my project.

    swc file (coltware_airxlib_rXX.swc) in airxmail project libs forlder.

    or if you want to knoww the airxlib project url,
    please see the following url

    http://code.google.com/p/airxlib/

    Source code:
    http://code.google.com/p/airxlib/source/browse/

    Regards

  • rouboxy より:

    Hello, Coltware! Thank you for airxmail. It is very useful library. I’d like to repeat question asked by Zayd. How could I use a ProgressEvent to monitor how much of the mail has been sent so far?

    rouboxy

  • rouboxy より:

    Is there any answer?

    rouboxy

  • coltware より:

    hi
    so sorry, reply was late.
    i am in holidays this week.
    so please a wait a few days.

  • rouboxy より:

    ок

  • coltware より:

    Hi rouboxy.

    I committed to support smtp progressEvent on r132(google svn).
    http://code.google.com/p/airxmail/source/detail?r=132

    code sample …

    sender = new SMTPSender();
    sender.addEventListener(ProgressEvent.PROGRESS,progressHandler);

    private function progressHandler(event:ProgressEvent):void{
    trace(“progress…” + event.bytesLoaded + “/” + event.bytesTotal);
    }

  • rouboxy より:

    Hi, coltware! Thank you very much!

  • Oliver より:

    Hey Guys,

    just one question: is it possible to generate a automatic job wich sets up some input text to a pdf an then attaches it to an email….

    i just startet to generate an PDF Document with alivePDF and then made a new email…just like im doing it here but i dont know how to give my email the attachment! look at the ???????????????? wich i’ve placed in the code …

    private var myPDF:PDF;

    public function generatePDF( displayObject:DisplayObject ):void
    {
    // we create the PDF
    myPDF = new PDF( Orientation.PORTRAIT, Unit.MM, Size.A4 );
    // we set the zoom to 100%
    myPDF.setDisplayMode ( Display.FULL_WIDTH );

    // we add a page
    myPDF.addPage();
    myPDF.addImage(displayObject);

    generateEmailAttachment(displayObject);

    }

    protected function generateEmailAttachment(displayObject:DisplayObject):void
    {

    var bodyTxt:TextArea = new TextArea;
    var fromtxt:TextArea = new TextArea;
    var totxt:TextArea = new TextArea;
    var ccTxt:TextArea = new TextArea;
    var subjectTxt:TextArea= new TextArea;

    // How to send plain text email
    var sender:SMTPSender = new SMTPSender();
    sender.setParameter(SMTPSender.HOST,”xxxxxx”);
    sender.setParameter(SMTPSender.PORT,25xx); // default port is 25
    // If you use SMTP-AUTH
    sender.setParameter(SMTPSender.AUTH,true);
    sender.setParameter(SMTPSender.USERNAME,”xxxxxxxxx”);
    sender.setParameter(SMTPSender.PASSWORD,”xxxxxxx”);

    // Create email message
    var message:MimeMessage = new MimeMessage();
    message.setTextBody(bodyTxt.text);

    // Set from email address and reciepients
    /* var from:INetAddress = new INetAddress(“xxxxxxxx”,”xxxxxxx”); */
    var from:INetAddress = new INetAddress;
    from.address = fromtxt.text;
    message.setFrom(from);

    var toRecpt:INetAddress = new INetAddress;
    toRecpt.address = totxt.text;
    message.addRcpt(RecipientType.TO,toRecpt);

    var ccRecpt:INetAddress = new INetAddress;
    ccRecpt.address = ccTxt.text;
    message.addRcpt(RecipientType.CC,ccRecpt);

    // create subject // Betreff erstellen
    message.subject = subjectTxt.text;
    // set subject // Betreff setzen
    message.setSubject(message.subject);
    // set body // Body setzen
    message.setTextBody(message.bodyText);

    var filePart:MimeImagePart = new MimeImagePart();
    filePart.setAttachementFile(???????????????????)

    if(fromtxt.text == “” && totxt.text == “” )
    {
    SkinnableAlert.show(“Bitte Absender und Empfänger benennen.”)
    }
    else
    {
    sender.send(message);
    sender.close();

    }

    }

    }

    ________________________________________

    thx in advance

  • coltware より:

    Hi Oliver

    Are you want to attach the file and send e-mail ?

    If you want to so,
    Please add the following the code after setAttachmentFile(?????)

    message.addChildPart(filePart);

    Regards

  • Tim より:

    Coltware,

    Thank you! Thank you! Thank you!

    Wonderful work.

  • Don より:

    Hi Coltware!

    Thank you for your codes and script. I’ll be using it in a simple survey project that runs on Android. I have already made some tests, and was able to send the email with attachment to the specified email address. I have one problem though, the attachment I am attaching to the mail is a .csv file. Although I am able to receive the email with attachment, it seems that when I receive them, the attachment was already of a different file type and file name (ex. original attachment is named as MyText.csv, when I receive the email, its attachment name is ATTXXXXXX.dat). When I open this file in Excel, the data was correct.

    How come I cannot preserve the original filename of the attachment?

    I have specified the filetype as follows:
    var filePart:MimeBinaryPart = new MimeBinaryPart()
    filePart.contentType.setMainType(“document”);
    filePart.contentType.setSubType(“csv”);
    filePart.setAttachementFile(File.documentsDirectory.resolvePath(“MyText.csv”));
    message.addChildPart(filePart);

    Is there something wrong in the code above? Thanks in advance. Appreciate you sharing your code with us.

  • Don より:

    Hi Colton!

    Im trying to send an email with a CSV attachment. Ive already spcified the contentType as “csv”, however when i receive the mail, the attachment filename changes – ATTxxxxx.dat instead of the original filename which is mytext.csv. How do I specify the content type as csv file?

  • Tim John より:

    You could try overriding the file name of the file part after specifying it:

    filePart.contentType.setParameter(“name”, “mytext.csv”);
    filePart.contentDisposition.setParameter(“filename”, “mytext.csv”);

  • Carlos より:

    Hi i’m sure I was able to send mail with gmail smtp.mail.com at port 587 using tls

    but now i’m getting the following error:

    I DONT KNOW HOW TO HANDLE DER stuff of TYPE 12
    I DONT KNOW HOW TO HANDLE DER stuff of TYPE 12
    I DONT KNOW HOW TO HANDLE DER stuff of TYPE 12
    I DONT KNOW HOW TO HANDLE DER stuff of TYPE 12
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.hurlant.crypto.cert::X509Certificate/getCommonName()[C:\ws\Crypto\com\hurlant\crypto\cert\X509Certificate.as:215]
    at com.hurlant.crypto.tls::TLSEngine/loadCertificates()[C:\ws\Crypto\com\hurlant\crypto\tls\TLSEngine.as:691]
    at com.hurlant.crypto.tls::TLSEngine/parseHandshake()[C:\ws\Crypto\com\hurlant\crypto\tls\TLSEngine.as:330]
    at com.hurlant.crypto.tls::TLSEngine/parseOneRecord()[C:\ws\Crypto\com\hurlant\crypto\tls\TLSEngine.as:228]
    at com.hurlant.crypto.tls::TLSEngine/parseRecord()[C:\ws\Crypto\com\hurlant\crypto\tls\TLSEngine.as:179]
    at com.hurlant.crypto.tls::TLSEngine/dataAvailable()[C:\ws\Crypto\com\hurlant\crypto\tls\TLSEngine.as:139]

  • coltware より:

    mmmm…

    exactly, i can say anything about tls handshake error.
    so i sometimes use securesocket.
    but it depends on smtp server.

    so i switch to use as3crpto lib or securesocket depends on smtp server.
    ex.
    gmail -> as3crpto (version 1.3)
    another smtp sever -> secure socket

    i don’t have good solution about tls socket yet.

  • Ricky より:

    Hi,Carlos, I had the same error like you,
    Now I have find a way to fixed this error,but I am not sure if it useful for you.
    You can download the as3cryto source code ,and add it to your project(com.hurlant)
    find com.hurlant.util.asn1.type.ASN1Type class,
    there is a function fromDERContent,modify it like this(the comments is the original code)
    protected function fromDERContent(s:ByteArray, length:int):* {
    return s.readBoolean();
    //throw new Error(“pure virtual function call: fromDERContent”);
    }

Leave a Reply

Spam protection by WP Captcha-Free

RSS
Add to Google
2010年3月
    5月 »
 123456
78910111213
14151617181920
21222324252627
28293031