Author: saqibkhan

  • Quota Management

    A quota in JavaMail is a limited or fixed number or amount of messages in a email store. Each Mail service request counts toward the JavaMail API Calls quota. An email service can apply following quota criterion: For Quota management JavaMail has following classes: Class Description public class Quota This class represents a set of…

  • Folder Management

    So far, we’ve worked in our previous chapters mostly with the INBOX folder. This is the default folder in which most mail resides. Some systems might call it as INBOX and some other might call it by some other name. But,you can always access it from the JavaMail API using the name INBOX. The JavaMail…

  • Gmail SMPT Server

    In all previous chapters we used JangoSMPT server to send emails. In this chapter we will learn about SMPT server provided by Gmail. Gmail (among others) offers use of their public SMTP server free of charge. Gmail SMTP server details can be found here. As you can see in the details, we can use either TLS…

  • Deleting Emails

    In this chapter we will see how to delete an email using JavaMail API. Deleting messages involves working with the Flags associated with the messages. There are different flags for different states, some system-defined and some user-defined. The predefined flags are defined in the inner class Flags.Flag and are listed below: POP protocol supports only…

  • Forwarding Emails

    In this chapter we will see how to forward an email using JavaMail API. Basic steps followed in the program below are: Here we have used JangoSMPT server via which emails are sent to our destination email address. The setup is explained in the Environment Setup chapter. Create Java Class Create a java class file ForwardEmail, the contents…

  • Replying Emails

    In this chapter we will see how to reply to an email using JavaMail API. Basic steps followed in the program below are: Here we have used JangoSMPT server via which emails are sent to our destination email address. The setup is explained in the Environment Setup chapter. Create Java Class Create a java class file ReplyToEmail, the…

  • Authentication

    In the previous chapters Checking Emails and Fetching Emails, we passed authorization credentials (user ad password) along with host, when connecting to store of your mailbox. Instead we can configure the Properties to have the host, and tell the Session about your custom Authenticator instance. This is shown in the example below: Create Java Class We will modify our CheckingMails.java…

  • Fetching Emails

    In the previous chapter we learnt how to check emails. Now let us see how to fetch each email and read its content. Let us write a Java class FetchingEmail which will read following types of emails: Basic steps followed in the code are as below: Create Java Class Create a java class file FetchingEmail, contents of which…

  • Checking Emails

    There are two aspects to which needs to understood before proceeding with this chapter. They are Check and Fetch. To check or fetch an email using JavaMail API, we would need POP or IMAP servers. To check and fetch the emails, Folder and Store classes are needed. Here we have used GMAIL’s POP3 server (pop.gmail.com). In this chapter…

  • Sending Emails

    Now that we have a fair idea about JavaMail API and its core classes, let us now write a simple programs which will send simple email, email with attachments, email with HTML content and email with inline images. Basic steps followed in all the above scenarios are as below: In the following sections we have…