AIR1.5

Additional requirements
as3crypto library

import com.coltware.airxmail.INetAddress;
import com.coltware.airxmail.MailSender.SMTPSender;
import com.coltware.airxmail.MimeMessage;
import com.coltware.airxmail.RecipientType;
// (Option) If you use TLSSocket
import com.hurlant.crypto.tls.TLSSocket;


private function send_plain_email():void{
	//  How to send plain text email
	var sender:SMTPSender = new SMTPSender();
	sender.setParameter(SMTPSender.HOST,"smtp.gmail.com");
	sender.setParameter(SMTPSender.PORT,465);  // default port is 25
	// If you use SMTP-AUTH
	sender.setParameter(SMTPSender.AUTH,true);
	sender.setParameter(SMTPSender.USERNAME,"username");
	sender.setParameter(SMTPSender.PASSWORD,"password");
	
	// If you use TLS/SSL
        // you can get as3crypto at http://code.google.com/p/as3crypto/
	var tlssocket:TLSSocket = new TLSSocket();
	sender.setParameter(SMTPSender.SOCKET_OBJECT,tlssocket);
	
	// Create email message
	var message:MimeMessage = new MimeMessage();
	
	//	Set from email address and reciepients
	var from:INetAddress = new INetAddress("from-email-address@xxxx.yyyy","from label");
	message.setFrom(from);
	
	var toRecpt:INetAddress = new INetAddress("to-email-address@xxxx.yyyy","to label");
	message.addRcpt(RecipientType.TO,toRecpt);
	
	var ccRecpt:INetAddress = new INetAddress("cc-email-address@xxxx.yyyy","cc label");
	message.addRcpt(RecipientType.CC,ccRecpt);
	
	//  
	message.setSubject("hello world");
	message.setTextBody("welcom !! \r\n this is first email. ");
	
	sender.send(message);
	sender.close(); 
}
Point
import com.hurlant.crypto.tls.TLSSocket;
:
var tlssocket:TLSSocket = new TLSSocket();
sender.setParameter(SMTPSender.SOCKET_OBJECT,tlssocket);
:

AIR2

Additional requirements

None

Point
import flash.net.SecureSocket;
:
sender.setParameter(SMTPSender.SOCKET_OBJECT,new SecureSocket());
:

Related Posts

7 Responses to “as3:How to use TLS socket in airxmail”

  • czalex より:

    I love it!!!
    thx.

    P.S.
    you have a typo

    var tlssocket:TLSSocket = new TLSSocket();
    sender.setParameter(SMTPSender.SOCKET_OBJECT,tlsobject);

    tlssocket != tlsobject <!

  • coltware より:

    Thank you.

    I fixed it.

  • DELL より:

    Getting error…
    Error #2044: Unhandled ioError:. text=Error #2031: Socket Error. URL: smtp.gmail.com

  • Will より:

    Is it possible to connect this to hotmail servers? The pop3 side works perfectly but the SMTP does not work correctly. It comes back with an IOError event.The server is smtp.live.com port 25 or 587. If i connect using a straight socket I get the responses for helo and starttls but then cannot execute it because of the straight socket being used. I would be grateful of any suggestions on this issue? Is there a separate type of auth mechanism for some servers?

  • coltware より:

    Hi will.

    I will try to connet hotmail server, but now I can’t connect ms live services.

    Can you see me communication messages log between server and this library ?
    I wrote the method in the following post.

    http://flex.coltware.com/2011/01/22/inside-airxmail/

    >Is there a separate type of auth mechanism for some servers?
    No. so sorry. I will think about it…

  • coltware より:

    I can connect and send e-mail using hotmail ( smtp.live.com:587).

    1 ) Server and port
    smtp.live.com ( port : 587 )
    2 ) use STARTTLS and as3crypto library
    please see at http://flex.coltware.com/2011/01/12/airxmail-how-to-use-starttls-extension-to-smtp2/

    I got a error message from server. like this
    550 5.3.4 Requested action not taken; To continue sending messages, please sign in to your account.

    Maybe you can see the error message in your hotmail mail box.
    Then I accessed http://mail.live.com, and sign in.

    And try again.

Leave a Reply

Spam protection by WP Captcha-Free

RSS
Add to Google
2010年7月
« 5月   8月 »
 123
45678910
11121314151617
18192021222324
25262728293031