[Request For Help] How To Send Email Midlet Using Secure Socket ?

Hello, this is the first time i ask for help to forum.sun.com.
i try to make secure connection for send email from MIDlet. Maybe you can check to my code :
EmailMidlet.java
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.;
public class EmailMidlet extends MIDlet implements CommandListener{
Display display = null;
// email form fields
TextField toField = null;
TextField subjectField = null;
TextField msgField = null;
Form form;
static final Command sendCommand = new Command("send", Command.OK, 2);
static final Command clearCommand = new Command("clear", Command.STOP, 3);
String to;
String subject;
String msg;
public EmailMidlet() {
display = Display.getDisplay(this);
form = new Form("Compose Message");
toField = new TextField("To:", "", 50, TextField.EMAILADDR);
subjectField = new TextField("Subject:", "", 15, TextField.ANY);
msgField = new TextField("MsgBody:", "", 90, TextField.ANY);
public void startApp() throws MIDletStateChangeException {
form.append(toField);
form.append(subjectField);
form.append(msgField);
form.addCommand(clearCommand);
form.addCommand(sendCommand);
form.setCommandListener(this);
display.setCurrent(form);
public void pauseApp() {
public void destroyApp(boolean unconditional) {
notifyDestroyed();
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if(label.equals("clear")) {
destroyApp(true);
} else if (label.equals("send")) {
to = toField.getString();
subject = subjectField.getString();
msg = msgField.getString();
EmailClient client = new EmailClient(this,"[email protected]", to, subject, msg);
client.start();
}and EmailClient.java
import javax.microedition.io.;
import javax.microedition.lcdui.;
import java.io.;
import java.util.Date;
public class EmailClient implements Runnable {
private EmailMidlet parent;
private Display display;
private Form f;
private StringItem si;
private SecureConnection sc; //SSL
private InputStream is;
private OutputStream os;
private String smtpServerAddress = "smtp.gmail.com"; //SSL
String from;
String to;
String subject;
String msg;
public EmailClient(EmailMidlet m, String from, String to, String subject, String msg) {
parent = m;
this.from = from;
this.to = to;
this.subject = subject;
this.msg = msg;
display = Display.getDisplay(parent);
f = new Form("Email Client");
si = new StringItem("Response:" , " ");
f.append(si);
display.setCurrent(f);
public void start() {
Thread t = new Thread(this);
t.start();
public void run() {
try {
//SSL
sc = (SecureConnection)
Connector.open("ssl://"smtpServerAddress":465"); //smtp with SSL port 465
sc.setSocketOption(SocketConnection.LINGER, 5);
is = sc.openInputStream();
os = sc.openOutputStream();
os.write(("HELO there" "\r\n").getBytes());
os.write(("EHLO" "\r\n").getBytes());
os.write(("auth login" "\r\n").getBytes());
os.write(("dHVnYXNha2hpci50cmlhZGl0eWFAZ21haWwuY29t" "\r\n").getBytes());
os.write(("dGEuZW1haWxjbGllbnQ=" "\r\n").getBytes());
os.write(("MAIL FROM:<">\r\n").getBytes());
os.write(("RCPT TO:<">\r\n").getBytes());
os.write("DATA\r\n".getBytes());
// stamp the msg with date
os.write(("Date: " new Date() "\r\n").getBytes());
os.write(("From: "+from"\r\n").getBytes());
os.write(("To: "to"\r\n").getBytes());
os.write(("Subject: "subject"\r\n").getBytes());
os.write((msg+"\r\n").getBytes()); // message body
os.write(".\r\n".getBytes());
os.write("QUIT\r\n".getBytes());
StringBuffer sb = new StringBuffer();
int ch = 0;
while((ch = is.read()) != -1) {
sb.append((char) ch);
si.setText("SMTP server response - " + sb.toString());
} catch(IOException e) {
e.printStackTrace();
Alert a = new Alert
("TimeClient", "Cannot connect to SMTP server. Ping the server to make sure it is running...", null, AlertType.ERROR);
a.setTimeout(Alert.FOREVER);
display.setCurrent(a);
} finally {
try {
if(is != null) {
is.close();
if(os != null) {
os.close();
if(sc != null) {
sc.close();
} catch(IOException e) {
e.printStackTrace();
public void commandAction(Command c, Displayable s) {
if (c == Alert.DISMISS_COMMAND) {
parent.notifyDestroyed();
parent.destroyApp(true);
} When I try to debug project from netbeans, i found this error :
Starting emulator in debug server mode on port 2668
Connecting to 127.0.0.1 on port 2800
nbdebug:
Waiting for debugger on port 2668
Waiting for KVM...
Running with storage root temp.SonyEricsson_JP8_128x160_Emu10
KdpDebugTask connecting to debugger 1 ..
Running with locale: Indonesian_Indonesia.1252
Connected to KVM
Connection received.
Attached JPDA debugger to localhost:2668
java.io.IOException: error 10054 during TCP read +
at com.sun.midp.io.j2me.socket.Protocol.nonBufferedRead(Protocol.java:299)+
at com.sun.midp.io.BufferedConnectionAdapter.readBytes(BufferedConnectionAdapter.java:99)+
at com.sun.midp.io.BaseInputStream.read(ConnectionBaseAdapter.java:582)+
at com.sun.midp.ssl.Record.rdRec(+41)+
at com.sun.midp.ssl.Record.rdRec(+5)+
at com.sun.midp.ssl.In.refill(+18)+
at com.sun.midp.ssl.In.read(+29)+
at EmailClient.run(EmailClient.java:74)+
Execution completed.
5145824 bytecodes executed
9258 thread switches
1762 classes in the system (including system classes)
0 dynamic objects allocated (0 bytes)
0 garbage collections (0 bytes collected)
debug:
BUILD SUCCESSFUL (total time: 4 minutes 34 seconds)
Regard
Littlebro

Don't multipost and don't use the browser's back button to edit your posts as that creates multiple postings. I've removed the other thread you started with the same questio.
Also, don't post to long dead threads. I've blocked your post and locked the thread you resurrected.
db

Similar Messages

  • Help: how to send emails from FORMS?

    Are there simple steps to send emails from FORMS?
    Thank you in advance.
    Jimmy

    I'm sure there are many ways to send emails from Forms. Personally I never had to do this, but I can imagine following ways.
    a) use UTL_SMTP-Package to send the email via your database
    b) use a Java-Call
    Peter

  • How To Send Email Without using password

    Hi Everyone
    I have Requirement like the one below
    1)i have to send emails without authentication is it possible? If yes please give me sample code

    1)i have to send emails without authentication is it possible?It is possible if the mail server you are connecting to doesn't require a password. This is most* unlikely.
    If yes please give me sample codeJust don't set the password, this is not rocket science.

  • Can u tell how to send the pictures using datagrams sockets in java

    hi to all, i am making chat application , i am datagrams socket(packets) for sending and receiving messages . datagrams only send and receive messages in bytes . can u tell me how to send the picture to other person using datagrams.
    Thankyou.

    look her
    http://forum.java.sun.com/thread.jsp?forum=31&thread=330989&tstart=0&trange=15
    and look up Serialisation

  • How can I get iTunes to answer my requests for help?

    I have tried for a few days now to get iTunes to help me get some tunes that partially downloaded. Their initial response seemed to work but the next day the tunes were only partially on my PC. I re-installed the software, called the phone number on my PayPal receipt, sent another e-mail request for help, responded to their follow up e-mail a few days ago asking if my issue was resolved.........and STILL cannot get them to help me resolve. They say I should receive a response within 24 hours, and it has been longer. No phone number to call, the initial instructions to re-download the missing tunes were confusing  

    It is quite easy to find out how to redownload purchases, using the search bar ( by Support) at the top of this page:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    You can contact itunes support again by clicking Support at the top of the page, then clicking the link under Contact Us.

  • How to send email notification in different languages in Workflow ?? Urgent Help Needed

    Gurus,
    How to send email notification in different languages in Workflow? Can anyone send me some useful guidelines or link where it is mentioned.

    There is no profile option available to specify whether send or not send email notification.
    But after login, in preferences youcan set the notification preference value by which you can configure whether to send or not
    to send email notifications.
    If you select ''Do not send me mail' or 'Disabled' it will not send.
    For other values it sends the notfication in different formats like text, html, attachments etc...
    Edited by: sarojak on Jun 27, 2011 7:18 AM

  • How to send emails to spam folder?

    I just got my Note4 and the phone's Help tells me that I need to select the email, then the bottom menu will populate with a little red circle with a + in it. I am to click that and the email address is sent to spam. But my bottom menu is NOT giving me that spam icon to click.  How can I block emails? Or how can I get that little icon to show up?
    Thanks!!

    Yes, I have unsubscribed to the emails that allowed me too. Now I would
    like to block spefic addresses and/or domains.
    My email addresses are @verizon.net, @gmail.com and a corporate one. I am
    using Gmail for the Gmail accounts and using the default email service that
    came on the phone. It's icon is an envelope with a red @
    I know the gmail service allows me to easily click "report spam"  but using
    note 4  how can I block emails in my  verizon.net account and corporate
    account?
    Thanks.
           <https://community.verizonwireless.com>
    A message from the Verizon Wireless Community
    <https://community.verizonwireless.com>
    <https://www.verizonwireless.com/wcms/consumer/explore.html> 
    <http://www.verizonwireless.com/wcms/consumer/shop.html>  [image: MY
    VERIZON] <http://www.verizonwireless.com/b2c/myverizonlp/> 
    <http://www.verizonwireless.com/support/>
       how to send emails to spam folder?  created by Verizon Wireless Customer
    Support <https://community.verizonwireless.com/people/vzw_customer_support>
    in Android - View the full discussion
    <https://community.verizonwireless.com/message/1176922#1176922>

  • How to send email through jsp

    can anyone please help me ...
    how do we send an email from a jsp page to any gmail,hotmail,yahoomail etc....
    what is the code for that
    if anybody know the solution it will be greatly appreciated ..
    regards
    santhosh
    9341208148

    I have a writeup that shows how to use JavaMail. It presents my EmailDelivery class (and example of how to use it) which I wrote to help me easily send emails from my Java applications using JavaMail. It supports relaying through SMTP servers that require authentication and has convenience methods for easily adding file attachments.
    Check it out at:
    http://timarcher.com/?q=node/53

  • [SOLVED]How to send email to a local user?

    I have installed Mutt, msmtp, procmail and I can send and receive emails to/from remote hosts and I'd like to send email locally also (to the recipients on the same machine as the sender).
    When I try to send email to a local user from the root account -
    echo "Test message" | mail -s "Test subject" localuser
    then I get an error that connection to the port 25 is refused. Because the /etc/msmtprc file contains the 'localhost' as the default account's host, and on the local host I don't have a mail server listening on 25 port running.
    When I try to send email from a non-root account which has in /$HOME/.msmtprc file a real email account on a remote server, then of course there is an error that the domain for the email address 'localuser' is not recognized.
    How can sending email to local users be enabled?
    Last edited by nbd (2014-09-30 22:33:37)

    If I understand correctly, postfix it's a constantly running daemon. Seems to be an overhead for delivering only from time to time sent messages.
    ewaller wrote:
    > Out of the box, sendmail should be safe, but I think you have to enable local mail.
    Currently I have msmtp-mta installed, which is described as having sendmail functionality. If I install sendmail - will it be possible to send local email without running email daemons?

  • How to send email in labview in intranet network

    hii all...
    i am quite new to networking concept in labview...
    i want to develop a ayatem where on completion of particularevent an email will be sent to concerned person regarding the completion of task...ans the email should be autogenerated....meaning that on completion of task directly email should me send to concerned persion programatically......This system will work for office only...
    i have tried to send email by using outlook...but i m having doubts..
    1)when i send mail using outlook in labview it is shown in outbox(of outlook) but the sent mail i didnt receive in inbox.i have not created the account on outlook.is the problem is related to this?
    2)what server address should i give if i want to use SMTP vi's??
    plz help me regarding this...
    thanks....

    smercurio_fc wrote:
    Shruti G wrote:
     2)what server address should i give if i want to use SMTP vi's??
    The same server that Outlook connects to. Do you have an internal server or an external server (i.e., one provided by your ISP or perhaps your domain name hosting service)? If it's internal is it a POP server, or MS Exchange, or ... ?
    One relatively easy way to figure this out is to Google "MX Lookup".  Go to one of those sites and enter the name of your domain, e.g. "somecompany.com".  The MX lookup page will return the name and/or IP of the SMTP server for the domain.  The MX lookup retrieves DNS information for the domain that is used to route email between servers.

  • How to send emails using Automatic Work Items in Collections using XML Publ

    Hi,
    We are using XML Publisher to send correspondances in Advanced Collections.
    We want to send email correspondances using Automatic Strategy Work Items.
    Can anybody please help on how to send these?

    I believe you have to define your dunning template and assign that template to the strategy work item.
    Let me know if you are still not able to do it.
    Thanks,
    Anil

  • Transport request for Help LaunchPad : K900033.N73

    Dear friends,
    Can anyone please tell me where to find transport request for Help LaunchPad K900033.N73 ?
    (We had raised a OSS 161317/2014 and this has been recommended by Shu Liu )
    We have SAP System with SAP_BASIS 740.
    I tried to work with SAP Note1799002 - How to choose Help LaunchPad files from uPerform Installation PackageI .. but did not managed to find this.
    best regards
    ashish

    Hi Anish,
    Sorry for delay.
    I see that Ancile have answered your question. Hopefully this is to your satisfaction.
    Regards,
    Matthew

  • How to send emails from of pdf's generated by oracle reports

    I have several pdf documents , I want to email those pdf's . Please let me know how to send emails from oracle reports .
    Thanks,
    Previn

    I have integrated Oracle Reports with Oracle Portal and used the scheduling feature via portlets. We have reports that run every monday morning for management. For more info go to:
    http://otn.oracle.com/products/reports/htdocs/getstart/demonstrations/index.html
    OR
    I think if you set destype=mail, desformat=PDF, and desname=[email protected] that should also do the trick.
    Just be sure that you have put your mail server's IP address in the rep_<machine_name>.conf file located in your <oracle_home>/reports/conf directory. If this is not set up, the mail feature won't work.
    Martin

  • Just want to find out how to send email? Can receive just fine, but cant send?!?!

    Hi Just wanted to find out how to send email? can receive just fine but cant send. Using hotmail at the moment.
      Any help would be great
    Thanks

    go to your mail providers setup guide and compare every single setting to how your smtp setup in your settings are set
    and if they are not the same change yours to match their page
    and if they are the same contact your isp to inquire as to why they are blocking the ports your mail provider are using

  • A Request for help from me again! Yay!

    hi guys! I was working on implementing threads for the directions of the unit. When i press forward once...nothing happens, but when i press twice it gives me this HUGE list of errors. I dont have a clue. Again, any help would be appreciated.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class NBoard extends JFrame implements KeyListener{
         int selection = 0;
         boolean selectionmade = false;
         final int WIDTH = 600;
         final int HEIGHT = 600;
         Image Viz =Toolkit.getDefaultToolkit().getImage(JOptionPane.showInputDialog("What character do you want?")+".gif");
         int XC = 50;
         int YC = 50;
         Thread moving = new Move();
         Unit Host = new Unit();
         public NBoard(){
              this.setSize(WIDTH,HEIGHT);
              selection = Integer.parseInt(JOptionPane.showInputDialog("What level design do you want?"));
              if(selection > 0){
                   selectionmade = true;
              addKeyListener(this);
              this.setVisible(true);
         public static void main(String args[]){
              new NBoard();
         public void paint(Graphics g){
              if(selectionmade == true){
                   if(selection == 1){
                        g.setColor(Color.white);
                        g.fillRect(0,0,WIDTH,HEIGHT);
                        g.setColor(Color.black);
                        g.drawLine(WIDTH/2,0,WIDTH/2,HEIGHT);
                   if(selection == 2){
                        g.setColor(Color.white);
                        g.fillRect(0,0,WIDTH,HEIGHT);
                        g.setColor(Color.black);
                        g.drawLine(WIDTH/2,0,WIDTH/2,HEIGHT);
                        for(int ctr = 1; ctr < 6; ++ctr){
                             g.drawRect(WIDTH/4 ,ctr * 100, 20, 20);
                             g.drawRect((WIDTH / 3) * 2 ,ctr * 100, 20, 20);
                   if(selection == 3){
                        g.setColor(Color.white);
                        g.fillRect(0,0,WIDTH,HEIGHT);
                        g.setColor(Color.black);
                        g.drawLine((WIDTH/2) - 90,0,(WIDTH/2) + 90,HEIGHT);
                   g.drawImage(Viz,XC,YC,this);
              public void keyPressed(KeyEvent e){                              //The Problem Areas
                   if(e.getKeyChar() == 'w'){
                        moving.start();                                             //Starting the thread to move up
                   else if(e.getKeyChar() == 's'){
                        YC = YC + 2;
                   else if(e.getKeyChar() == 'a'){
                        XC = XC - 2;
                   else if(e.getKeyChar() == 'd'){
                        XC = XC + 2;
                   System.out.println(e.getKeyChar());
                   repaint();
         public void keyReleased(KeyEvent e){                              //The Problem Areas
              if(e.getKeyChar() == 'w'){
                   moving.interrupt();                                             //Trying to interrupt the thread once the key is released
         public void keyTyped(KeyEvent e){}
    class Move extends Thread{                                                  //The Problem Areas
         public void run(){                                                       //The Thread
              Unit.XC = Unit.XC - 2;
              try{
                   Thread.sleep(1000);
              catch (Exception e){}
    class Unit{                                                                      //The Object which will hold all of the information about each unit
         static int XC = 30;
         static int YC = 30;
    } By the way, here is my order of events, so you can look forward to seeing requests for help for them (hopefully not).
    Threads: Moving the guy around
    Threads: Making him shoot a ball at the mouses position
    Network: Allow others to join/play game (This is gonna be HUGE probably), while host decides on game type.
    Thanks for all the help so far!

    Where does moving ever get started? Why does Move extend Thread instead of implementing Runnable? (Implementing runnable is preferred and often the correct way to do it and it is in this case)
    But regardless there shoud be a moving.start() somewhere or start of the Thread that has the Runnable target Move.... I don't think I see one. Unless I missed it.
    so...itll work if i change the setup to Runnable?

Maybe you are looking for

  • How do I add multiple JPanels to a JFrame?

    I've been trying to do my own little side project to just make something for me and my friends. However, I can't get multiple JPanels to display in one JFrame. If I add more than one JPanel, nothing shows up in the frame. I've tried with SpringLayout

  • 2012 MacBook Pro freezing and shutting down randomly

    I have a 2012 MacBook Pro (15.4" 2.6ghz i7 model) and I'm having some serious issues with the laptop freezing up completely and also randomly restarting. The freezes are hard freezes as well, not simple hangs, they require me to hold the power button

  • Ugh/ kernal panics / apple hardware test will not boot / help

    so my first thought is to replace all my memory and I even have some coming via OWC -- but it seems silly just to replace memory on a hunch and randomly. So I run rember and get an all cler on all my memory. Can this really be soo? So I think - try t

  • Number of times a particular vendor has exceeded the threshold limit

    Hello, We wish to find the number of times a particular vendor invoice has exceeded tolerance limit.  Is there any table where this data gets updated or is their any standard report ? Regards Jayesh.

  • Best method for 8 channel analog control on a microsecond scale

    Thanks for the quick reply, it was most helpful. Now that I am restricted to the analog channels I was just wondering as to the best method of control. At present I am using the AO Generate waveforms VI, by feeding it a pre-built arrays of data for e