title: Read sent mails using smtp java
body: <p>I have been trying lot of things from multiple resources like <a href="http://www.java2s.com/Code/JavaAPI/javax.mail/SessiongetStoreStringname.htm" rel="nofollow noreferrer">Read Inbox Java2s</a>
  and <a href="https://stackoverflow.com/questions/4790844/how-to-get-the-list-of-available-folders-in-a-mail-account-using-javamail">How to get the list of available folders in a mail account using JavaMail</a></p>
  
  <p>I am sending emails succesfully, <strong>but to be sure of mail is sent successfully, i need to read emails from sent items folder</strong> Is this possible with smtp? if yes, how?</p>
  
  <p>Currently I am stuck even in connceting with stroe. I am finding no way to pass the steps
  <code>Store store = session.getStore();</code> and <code>store.connect();</code></p>
  
  <p>I have no idea about <code>imap</code> or <code>pop3</code>. They might not have been even configured at our server, but if <code>smtp</code> does not faicilitate then I am ready to process with those protocols, though I am sending mails using <code>stmp</code> yet. I have tried lot of edits in my following code, but nothing is helping</p>
  
  <pre><code>        String host = "mysite.smtp.com";
          Properties props = new Properties();
          props.put("mail.smtp.starttls.enable", "true");
          props.put("mail.smtp.host", host);
          props.put("mail.smtp.port", "myport");
          props.put("mail.smtp.auth", "true");
  
  
          Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
              protected PasswordAuthentication getPasswordAuthentication() {
                  String user = "myname";
                  String password = "mypassword";
                  return new PasswordAuthentication(user, password);
              }
          });
          Store store = session.getStore(); // had tried writing "imaps" here
          store.connect(host, null, null);
          //store.connect(); also tried this
  
          Folder inbox = store.getFolder("INBOX"); //actually i need "SENT"
          if (inbox == null) {
            System.out.println("No INBOX");
            System.exit(1);
          }
          inbox.open(Folder.READ_ONLY);
  
          Message[] messages = inbox.getMessages();
          for (int i = 0; i &lt; messages.length; i++) {
            System.out.println("Message " + (i + 1));
            messages[i].writeTo(System.out);
          }
          inbox.close(false);
          store.close();
  </code></pre>