Results 1 to 15 of 15

Thread: Javamail

  1. #1
    v_mallikarjun is offline Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    0

    Default Javamail

    javax.mail.MessagingException: Connect failed;
    nested exception is:
    java.net.ConnectException: Connection refused: connect
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3St ore.java:161)
    at javax.mail.Service.connect(Service.java:288)
    at javax.mail.Service.connect(Service.java:169)
    at mail.Test9.main(Test9.java:37)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.sun.mail.util.SocketFetcher.createSocket(Socke tFetcher.java:233)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFe tcher.java:189)
    at com.sun.mail.pop3.Protocol.<init>(Protocol.java:94 )
    at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java :214)
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3St ore.java:157)
    ... 3 more


    The above is the exception while executing connect statementfor the code given below, Can anyone help me out please my final year project end date is approaching





    package mail;

    import java.io.FileInputStream;
    import java.util.Iterator;
    import java.util.Properties;

    import javax.mail.Folder;
    import javax.mail.Message;
    import javax.mail.Session;
    import javax.mail.Store;

    public class Test9 {
    public static void main(String[] args) {
    Properties prop = new Properties();
    FileInputStream file = null;

    try{
    int j = 0 ;
    file = new FileInputStream("C:\\new\\MailProperties.txt");
    prop.load(file);
    Iterator it = prop.keySet().iterator();
    String values[] = new String[5];
    String keys[] = new String[5];
    while(it.hasNext()) {
    String key = (String)it.next();
    String value = prop.getProperty(key);
    keys[j] = key;
    values[j] = value;
    j++;
    }
    String host = values[1];
    String username = values[2];
    String password = values[0];
    prop.put("mail.pop3.host", host);
    Session session = Session.getDefaultInstance(prop, null);
    Store store = session.getStore("pop3");
    store.connect(host,username, password);
    Folder folder = store.getFolder("Inbox.dbx");
    folder.open(Folder.READ_ONLY);
    Message message[] = folder.getMessages();
    //Display from (only first) and subject of messages
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": "
    + message[i].getFrom()[0]
    + "\t" + message[i].getSubject());
    System.out.println(message[i].getContent());
    }
    folder.close(false);
    store.close();
    } catch(Exception e) {
    System.out.println(e);
    }
    }
    }

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    What specificly this program will do?

    And when asking help, please be also specific....

    regards,
    sukatoa

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Provide more details about your question. And also please read our FAQ page before posting next time.

    At the time if you don't have enough time to read it, please put your code withing code tags.
    Last edited by Eranga; 04-17-2008 at 09:53 AM.

  4. #4
    v_mallikarjun is offline Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    0

    Default Javamail

    This program should recieve mail from mail server and display on the console using javamail, but not doing so. thanks for your interest.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Ok, what is your mail server. Your own coding one or an open source. There are lots of open sources servers. May be an Apache have a solution for you.

    First think about the mail server you going to use.

  6. #6
    v_mallikarjun is offline Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    0

    Default Javamail

    I work for a company, It is mail server in my company. Thanks for your interest

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Ok, did you solve the problem? Seems to me, depend on your error code put in the first post, there is a connection error may be.

    I can see a connection refused exception on the second line of the error code.

  8. #8
    v_mallikarjun is offline Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    0

    Default javamail

    No, I could not solve the problem. I gave username and password properly not able to connect to mail server.

  9. #9
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default


    Check proper IP Address of your mail server and disable Virus scan software like McAfee.

    sanjeev

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by sanjeevtarar View Post

    Check proper IP Address of your mail server and disable Virus scan software like McAfee.

    sanjeev
    Yep, firewall too.

  11. #11
    v_mallikarjun is offline Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    0

    Default javamail

    Ok i will do that, is there anything related to proxy server, through we connect.

    Thanks anyways

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by v_mallikarjun View Post
    No, I could not solve the problem. I gave username and password properly not able to connect to mail server.
    That's what I try to pointed pal. As I said, your exceptions list give an idea to me that it's all about your network connection. Something wrong with it. :)

  13. #13
    v_mallikarjun is offline Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    0

    Default

    ok sure i will give a try, thanks

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Ok, try it an see.

    At the same time mallikarjun, next time if you want to delete a replay please contact one of our moderator. They can do it safely for you :)

  15. #15
    v_mallikarjun is offline Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    0

Similar Threads

  1. Using JavaMail API
    By consult4u in forum Networking
    Replies: 0
    Last Post: 08-09-2007, 11:15 AM
  2. Sending mail Using JAVAMAIL
    By peiceonly in forum Advanced Java
    Replies: 3
    Last Post: 07-19-2007, 03:11 PM
  3. This is Regarding JSP with javamail
    By venkatkomalli in forum Advanced Java
    Replies: 3
    Last Post: 07-19-2007, 03:07 PM
  4. 530 5.7.0 Authentication Required - JavaMail gmail
    By simon in forum Advanced Java
    Replies: 1
    Last Post: 07-15-2007, 12:52 AM
  5. JavaMail:Authentication required error
    By bbq in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 05:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •