Can Send but not Read using JavaMail

I have use the simple program to send email using smtp server from my company. It runs fine. However, when i try to run the program of reading the message from my INBOX, i have receive error of the following..I am sure that my company's smtp server works since i have no trouble sending email to my account.
Could anybody help on this? the source code is here.
Source Code
=======================================================================
import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class GetMessageExample {
public static void main (String args[]) throws Exception {
Store store = null;
Folder folder = null;
try
          String host = args[0];
          String username = args[1];
          String password = args[2];
          // Create empty properties
          Properties props = System.getProperties();     
          // Get session     
          Session session = Session.getDefaultInstance(props);
          session.setDebug(true);
          // Get the store
          store = session.getStore("pop3");
          // Connect to store
          if ( host != null && username != null && password != null)
               store.connect(host, username, password);
          // Get folder
          folder = store.getFolder("INBOX");
          // Open read-only
          folder.open(Folder.READ_ONLY);
          BufferedReader reader = new BufferedReader (
          new InputStreamReader(System.in));
          // Get directory
          Message[] message = folder.getMessages();
          for (int i=0, n=message.length; i<n; i++) {
          // Display from field and subject
               System.out.println(i + ": " + message.getFrom()[0] + "\t" + message[i].getSubject());
               System.out.println("Do you want to read message? [Y to read/Q to end]");
               String line = reader.readLine();
               if ("Y".equals(line))
                    // Display message content
                    System.out.println(message[i].getContent());
               else if ("Q".equals(line))
                    break;
          // Close connection
          folder.close(false);
          store.close();
catch(Exception e)
          e.printStackTrace();
========================================================================
C:\>java GetMessageExample [my company SMTP server] [my user name][my password]
DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.
POP3Store,Sun Microsystems, Inc]
POP3: connecting to host "my company SMTP server", port 110
javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:106)
at javax.mail.Service.connect(Service.java:234)
at javax.mail.Service.connect(Service.java:135)
at GetMessageExample.main(GetMessageExample.java:39)

Dude SMTP is a TRANSFER potocol!! you need a store to collect your messages from. You need to enter your company's pop or imap server not smtp server.

Similar Messages

  • Can send but not retrieve emails using Thunderbird and Windows 8.1

    Hi, I am not able to get Thunderbird to retrieve emails on a new laptop.
    Last week I purchased a new laptop due to an imminent hard disk failure on my old laptop. I will call them "Old" and "New" laptops. (Old laptop is still working for the moment...)
    The Old laptop is nearly 3 years old, and I have been using Thunderbird on it since new without any problems.
    I have downloaded and installed Thunderbird on the New laptop, and can not get it to retrieve emails.
    As the Old laptop is still working (at the moment), I am able to directly visually compare and check settings on both computers.
    THE PROBLEM
    Using Thunderbird on the New laptop, I am able to send emails, I can see all my old emails restored from the Old laptop using Mozbackup, but clicking Get Mail on the New laptop does not retrieve new
    emails.
    When I click Get Mail, the status message in the bottom left corner says "connected to .....<ISP>..." but does not actually get the emails. However, the Old laptop is still able to get emails as it always has.
    My ISP is a large Australian telco that I have used for many years and I have not changed anything with my account. The ISP is POP3.
    WHAT HAVE I TRIED
    I deleted the email account created by restoring from Mozbackup, and attempted using the Thunderbird new account wizard, however Thunderbird did not recognise my ISP and would not create the account - even though it is working perfectly at the same time on the Old laptop.
    All Firewalls I can find have been configured to allow Thunderbird, with the same configuration settings on both machines.
    How do I know I can send but not Get emails from Thunderbird on the New laptop?
    I have sent test emails to myself from the New laptop. Thunderbird sends successfully, I am able to preview the test emails via Mailwasher on the New laptop, and can read, reply, etc, to the emails if I log into my ISP webmail service. However I can NOT get Thunderbird to retrieve and download these emails on the New laptop. If I go to the Old laptop, Thunderbird works perfectly, retrieves and downloads all new emails, including these test emails.
    I am now at the point where I do not know what else to try and would appreciate any suggestions.....
    I have spent many hours over the last 3 days surfing the net, forums, Mozilla Support, etc, and tried everything suggested, without success. The only thing I have NOT tried is starting windows in Safe mode (as per some suggestions), as it is not a viable long term solution.
    OTHER INFO
    Computer Details;-
    "Old" laptop;-
    Windows 7 Home Premium - continuously updated with all Critical and Important updates. 64 bit version.
    Antivirus = Bitdefender Total Security (subscription and licensed). Up to date.
    MailwasherPro 2012 (subscription and licensed). Up to date.
    Thunderbird 24.5.0 working perfectly. Up to date.
    "New" laptop;-
    Windows 8.1 - up to date with all Critical and Important updates. 64 bit version.
    Antivirus = Bitdefender Total Security (subscription and licensed) - downloaded and installed. Up to date.
    MailwasherPro 2012 (subscription and licensed) - downloaded and installed. Up to date.
    Thunderbird 24.5.0 - downloaded and installed.
    Note: I 'downloaded and installed' the Windows 8.1 version of these programs to avoid any potential compatibility problems restoring or copying from a Windows 7 backup version of the programs.
    1) New laptop came with pre-installed with McAfee - which has been Uninstalled due to running Bitdefender (Windows searches for 'McAfee' return nothing found suggesting the Uninstall was successful).
    2) Thunderbird has been added to both Bitdefender and Windows 8.1 firewalls on the New laptop.
    3) Bitdefender and Windows security settings are identical on both laptops - as near as I can determine, I may be missing something - but have checked all settings 3 times by doing a side-by-side visual comparison.
    4) Thunderbird settings are also identical and I am using the same email address and ISP that I have been using for many years.
    5) I migrated Thunderbird settings, accounts and emails from the Old laptop to the New laptop using Mozbackup, then visually checked and compared all settings in Thunderbird between the two machines.
    6) For info, I have used Mailwasher for many years as a simple way to preview and wash mail before running email programs such as Thunderbird - might be overkill, but I have also never had a virus or malware problem, so will keep doing this.
    7) I have Uninstalled and re-installed Thunderbird on the New laptop twice, and done the same with Bitdefender once.
    8) Any config changes I try on the New laptop, I either restart Thunderbird and / or restart the New laptop, or both.
    9) I have not created a Windows 8.1 account and am not using SkyDrive.
    10) Only other software I have installed on the New laptop is Google Chrome, Office Home 2013 and iTunes - all are working.
    Thanks in advance....

    Well there is not much left. If telnet works then the path is clear and there is no hardware firewall blocking ports.
    All that is left is software, so try windows safe mode with networking. A very handy way to eliminate software. it also actually disables most anti virus resident features and is preferred here because anti virus/security programs do not always disable or turn off when they say they have.
    You might also try the McAfee removal tool. https://community.mcafee.com/thread/52788 I notice the rep said yes to both, they did not say not required.
    Finally you could try creating a new profile, and see if it works just to exclude corruption of your existing profile. ( I doubt it but I am at the anything goes point)
    Just as an aside, I have never had an email borne nasty and I for many years never even had an email virus scanner. So yes I think your a bit over cautious with mailwasher, if that is what your using it for. Thunderbird does not support scripting languages or flash, or most plugins in the email sandbox. The result is getting a virus from a mail in Thunderbird is really only possible, for all practical purposes, if you open that password protected zip from the young Russian woman and that is what the anti virus should be blocking anyway when the temp file is written.

  • Can suddenly not use emoji in textmessages. Can send but not recieve.

    can suddenly not use emoji in textmessages. Can send but not recieve.

    Are any of you going to the Adobe Developer Conference scheduled to be held for plugin providers at San Jose on Nov 7/8?

  • Using osx 10.7.5 can send but not receive emails. Mail server support rep tried everything

    Using iMac with OSX 10.7.5. Can send but not receive emails. No problem with internet account. Server rep tried everything and suggested perhaps a corrupted file in the op syst. Any ideas?

    You may have a corrupt preference. Mail - Preferences - Accounts - click the offending account and re-enter all prefereneces. Also you can use Apple's OS X Mail: Troubleshooting sending and receiving email messages located at:
    http://support.apple.com/kb/ts3276

  • I can send but not receive email

    Hello All. I know this is a highly posted topic but I cannot find a solution. Any help is greatly appreciated.
    Basic Problem- I can send but not receive email.
    My ISP is. Yahoo SBC Global
    I have a 3rd party email provider: 1and1.com
    I have set my preferences according to the specifications of 1and1.com
    The error I get is this: The server error encountered was: The attempt to read data from the server "pop.1and.com" failed.
    I have a Macbook Pro, running 10.4.9. My account with the 3rd party email provider is new and only has 1 or two emails in the account. I know this because I can log on via the internet and use their website to check the emails in the inbox. So the "email" address is working. I just can't get it to forward to my laptop.
    I'm wondering if it has something to do with port 110 being blocked by my ISP. But I really don't think they are blocking that port. Due to the fact that my previous computer was a dell, and I used a similar 3rd party provider to email, the account used port 110 and things worked fine.
    Thanks to all.

    Ok. I've got it working.
    All I did was delete my account information from the preferences. Before, I was editing it.
    I entered a completely new POP account and it started working. I have a hard time believing that I entered information incorrectly prior to this because I checked it, rechecked it had a friend check it and it all looked OK. I was copy and pasting information anyway.
    However, once I deleted and re- entered a brand new account, it worked fine.
    Ernie, thanks for replying to my emails! I appreciate it.
    -Fraky

  • E71 Imap, can send but not receive

    HI all
    I received my E71 about a week ago and having major problems configuring it with my work email.
    Its an IMAP mail. I can send fine but on most occasions cannot receive. Occasionally it downloads some mails but only twice in the last week. I think this shows the settings are correct.
    Have tried to sign up with Nokia mail but get the following error message:
    'Unable to connect with the information provided. Please try again.'
    My colleagues in the UK use Blackberrys fine and have spoken with IT and they cannot think of any reason why this is happening. I have deleted the mailbox and set it up again many times but still can send but not receive...
    Very grateful for any advice as really happy with the phone other than this which is the main reason why I bought it.
    Shane

    Hi Anne,
    Is this IMAP or POP account?
    Not certain, but this can fix myriad Mail problems...
    Safe Boot from the HD, (holding Shift key down at bootup), it will try to repair your Disk Directory while the spinning radian is happening, so let it go, run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, then move these folder & file to the Desktop.
    Move this Folder to the Desktop...
    /Users/YourUserName/Library/Caches/Mail/
    Move this file to the Desktop...
    /Users/YourUserName/Library/Mail/Envelope Index
    Reboot.

  • Upgraded to Tiger; Mail can Send, but not receive... help!

    Hi there,
    I've come across lots of issues people have had importing all their mailboxes when they've upgraded from Panther to Tiger, but my wife's problem is different - - Mail can Send, but not receive. 'Get Mail' hasn't worked since the upgrade. I've been on the phone with my POP server provider, and all my Mail Account settings are correct. I can send mail, as I say, and sure enough, there it is in her Hotmail web page, along with all the other messages people have sent her in the last two weeks...
    So why can't Mail 'get' these messages, if all the settings are correct?
    Any advice would be appreciated.
    Malcolm

    You’re welcome.
    If you deleted a POP account, then all the messages stored in that account’s mailboxes has certainly been wiped out, not just moved somewhere, and you were warned that this would happen by the following alert:
    Remove Account
    Are you sure you want to remove the <AccountType> account "<AccountName>"?
    This will permanently delete the account setup information, mailboxes, and messages from your computer. Messages stored on the mail server will not be affected.
    To prevent that from happening, you should have moved those messages to custom “On My Mac” mailboxes instead of leaving them in the account’s mailboxes. Actually, using Inbox and Sent for archiving purposes is a bad idea regardless.
    If the messages are not on the server and you don’t have a backup (which you should have made before doing something like that), you may try to salvage as many deleted *.emlx files as possible with a data recovery tool such as Data Rescue II, TechTool Pro, or FileSalvage (the files to be recovered would be different in the case of Mail 1.x). Of these, the only one I know for sure that can currently recover deleted *.emlx files is FileSalvage. Stop using your computer right now if you want to try that, as anything you do with the computer may cause the deleted files to be overwritten.

  • Have new iPhone 4. Attempting to set up Comcast email.  I can send but not receive.  Help please.

    I have new iPhone 4S.  Attempting to set up Comcast email.  I can send but not retrieve my Inbox directly from Comcast.  Please help.  Thanks.

    Contact comcast and get the correct server settings for use on a mobile device.

  • I have an iphone6. And out of the blue my group messages aren't working. I can send but not receiving any back.

    I have an iphone6. And out of the blue my group messages aren't working. I can send but not receiving any back.  Any ideas???  I already reset my phone twice.

    You should check that your settings (both directions) match this:
    IMAP (Incoming Mail Server) information:
    Server name: imap.mail.me.com
    SSL Required: Yes
    Port: 993
    Username: [email protected] (use your @me.com address from your iCloud account)
    Password: Your iCloud password
    SMTP (outgoing mail server) information:
    Server name: smtp.mail.me.com
    SSL Required: Yes
    Port: 587
    SMTP Authentication Required: Yes
    Username: [email protected] (use your @me.com address from your iCloud account)
    Password: Your iCloud password
    Note: If you receive errors using SSL, try using TLS instead.
    Your signature says you have 10.6.8 - is this correct? If you migrated from MobileMe using this your mail settings won't be correct and you will need to follow this procedure to re-enter them:
    Entering iCloud email settings manually in Snow Leopard or Leopard

  • Exchange mail- can send but not receive?

    Anyone had this problem?
    I have the mail app set up with my company's exxchange server as the incoming, outgoing and OUtlook webs access servers and no go, I can send but not receive in the app....
    -c

    Check with your Exchange administrator.

  • Can send but not get mail....

    This is strange - my mailserver has imap/ssl/password. Before 3.0 upgrade all worked fine (hm... except a couple of days when I just got my Iphone where actualle the very same problem showed up, but suddenly started to work).
    So, I can connect to server and send mail. But I can't connect to server to read/fetch mail (connection failed message).
    I've exact same configuration on my macbook - working like a charm. Tested to remove account on Iphone and recreate, resync, you name it. Still not possible to read, only send.
    Why???

    Anyone with any ideas are welcome....
    Now I dropped all mail accounts on the phone and resynched with iTunes to recreate all mail accounts. Still - one of the accounts will not work. Possible to send but not read mail. And it is working on the mac.
    regards,
    /L

  • Can send but not recevie mail - help please

    I have tried to push mail though, switched phone off and logged off on my desktop. But I can send but not receive.
    Any ideas?

    Hi Anne,
    Is this IMAP or POP account?
    Not certain, but this can fix myriad Mail problems...
    Safe Boot from the HD, (holding Shift key down at bootup), it will try to repair your Disk Directory while the spinning radian is happening, so let it go, run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, then move these folder & file to the Desktop.
    Move this Folder to the Desktop...
    /Users/YourUserName/Library/Caches/Mail/
    Move this file to the Desktop...
    /Users/YourUserName/Library/Mail/Envelope Index
    Reboot.

  • Can send but not receive email

    I have contacted my ISP and confirmed my password and settings. I can log on and send but not receive. The emails are on the server. This problem started after I installed the latest apple security update. The isp tech felt everything was ok there and that the problem was due to the security update blocking incoming mail.
    Any ideas on how to fix this?
    Henery
    powerbook15   Mac OS X (10.3.9)   mail version 1.3.11 (v622/624)

    Thanks, Dave!
    I had the same problem. Could send but not receive, on three email accounts all of which were on the same server. The other four accounts on two different serves worked fine. This was a sudden change and I had not changed any mail prefs for several weeks or anything on the server end in months. I spent 3.5 hours on this this evening, excahnging emails with customer suppert at the server (using the other accounts of course), going through the complicated webstie to check the server configuration, checking the prefs in mail over and over and over, setting up the email on another computer to discover it worked, throwing everything realted to these three accounts out of keychain thinking maybe it had saved an old password.
    Came in here to post a plea for help and read your message. The offline bits were set. And the list of accounts under the IN heading had been collapsed (I generally have it open, don't know how it was collapsed) so that I couldn't see the obvious offline indicator. !!!
    Thanks again! Where were you 3.5 hours ago?
    Bob H

  • I can send but not receive email using Mail and Comcast

    My incoming mail [Mac Mail 3.6(936) ] slowed and now has stopped. I get error message "mail.comcast.net" on port 995 timed out. I can send. I can receive at Comcast.net. I have tried changing the port setting to 101 and no SSL and 587 (the comcast online set up guide), etc. and sometimes it works once then fails again. I have deleted the p-list in the Mail Library and restarted and still nothing.
    I deleted the account and set it up again but still no luck. Oddly the Preferences says deleting the Accounts will delete everything but the Mailboxes are still there. Part of the problem?
    I do not have this issue using Thunderbird which is a program I do not like.
    I used Comcast's various online guides, a long useless chat and useless email to no avail. My Primary Account Holder email (which I never use) works but not my every day email account.
    MAC OS 10.5.8
    MacBook Intel Core Duo
    Mac Mail 3.6(936)

    *Sorry didn't see how old this thread was* Jono1968 if this could help you......
    Here is what I would try -
    Run the disk permissions utility....see if a repair works....
    On the mail menu, go to Window => Connection Doctor - do you see errors (red dot) If so, what does it say the error is caused by?
    Check this article out: http://support.apple.com/kb/ts1307
    Rick
    Message was edited by: rdvholtwood

  • TB stopped receiving emails after one with huge attachment. Updated TB. Can send but not receive. Using Yahoo POP server. Browser access works fine.

    Several days ago, after receiving a 7MB attachment, I stopped receiving email on my Yahoo POP account. Browser access to the Yahoo server works fine. I obviously deleted that message and attachment but curiously, it and only it continued to be downloaded to my inbox!!! I tried downloading a new TB and installing it. Nothing changed except that specific email no longer appeared (another did though, see later). Settings are to leave msgs on server until I delete them. I transferred all my inbox to a local folder and then compacted mail and tried testing reception from another source and nothing appeared on TB, just on browser access. Oddly, one very old message repeatedly appears, I assume as a result of the auto check for new mail but not sure. Though I try to delete this old message, I can't. I haven't removed and recreated account yet because I don't want to lose all the filter history. Scanned for solution and can't find any. Any ideas, please?

    Starting your mac in safe mode will disable the Symantec stuff long enough to download mail. Should the issue arise again
    [http://support.apple.com/kb/ht1564 OSX Safe mode instructions from Apple]

Maybe you are looking for