View RSS Feed

Java Mail

  1. Java Mail Authenticator

    by , 04-25-2012 at 10:09 PM
    Benefit of the Authenticator class might be taken by the Mail APIs, just like java.net packages. Protected resources are being accessed by this class by using Username/Password. This resource might be simple file, server or anything else. In case of Java Mail, server would be the resource. In essence, Authenticator object gets passed to getInstance()/getDefaultInstance() method as a parameter which controls the Session object’s security aspect.

    Authenticator could be used by 2 methods. ...
  2. Java Mail Protocols

    by , 04-25-2012 at 10:07 PM
    Protocols are those rules which declare the format to do communication among systems. Main protocols for mailing systems are given below:
    1. SMTP
    2. IMAP
    3. POP
    4. MIME

    Let's consider them one by one.

    1. SMTP:

    SMTP i.e. Simple Mail Transfer Protocol defines email delivery mechanism. For mail transfer, mail client makes contact to organization’s SMTP server which send message in turn to the SMTP server recipient. IMAP or ...
    Categories
    Mail API
  3. Read Multipart mail using Java Mail

    by , 04-25-2012 at 10:04 PM
    Multipart messages could be read by javamail api which has been shown in this example. Multipart class object is created to read the multipart mail.

    For composition of mails along with attachments, Multipart mail is being used now a days. One might attach the doc, images, zip files, xls etc. Mails that could be designed nicely are created by it.

    Classes are provided by the Java Mail API so that Multipart messages could be created, sent or read. Java Mail api is used ...
    Categories
    Mail API
  4. Send multipart mail using java mail

    by , 04-25-2012 at 10:02 PM
    By the help of java mail how one could send multipart mails has been shown in this example. One might think a Multipart to be a container which contains more than one body parts. For sending the multipart mail, Multipart class object is made. After this BodyPart class object is created and text is set in the BodyPart class object which is then added to Multipart class object. Ultimately message is sent. In the given code, Class Multipart is abstract class. In this program, method of Multipart class ...
    Categories
    Mail API
  5. Reading message using Java Mail

    by , 04-25-2012 at 09:58 PM
    To read the messages by the help of javamail api. , consider the given example. Folder Objects holds the stored messages. Folder might consist of messages or folders or both. Methods are declared by the Folder class so that to fetch, copy, append, copy or delete the messages. In this program, few used methods are given below:

    System.getProperties() system properties are obtained by this method.
    Session.getDefaultInstance(properties) Default Session object are obtained by this ...
    Categories
    Mail API
  6. Java Mail API Store and folder

    by , 04-25-2012 at 09:56 PM
    When session is obtained, connection is made b/w javax.mail.Store & host, authenticator, port, username/password. Store objects which are involved in implementation of specified protocol might be formed by protocol information passage to the getStore() method.

    Java Code:
    // create object of store class.
    Store store = session.getStore("pop3");
    store.connect(host, username, password);
    After connecting to store you need to get a folder that holds ...
  7. Java Mail API Address

    by , 04-25-2012 at 09:54 PM
    Address class is considered to be the abstract class hence class javax.mail.internet.InternetAddress will be used here.

    Address address = new InternetAddress("name@site.net");

    For name text to be displayed to Email add, one or more arguments shall be used for the name

    Java Code:
    Address address = new InternetAddress(“name@site.net”, ”name”);
    After address has been created, make connection with message by 2 ways:

    1: ...
    Categories
    Mail API
  8. Java Mail API Message

    by , 04-25-2012 at 09:51 PM
    When session object has been created, message is created so that to send it by the help of Message class. As message class is considered as abstract class hence subclass javax.mail.internet.MimeMessage will be used.
    Java Code:
    MimeMessage message = new MimeMessage(session) 
    // set the content of message by setContent() method
    message.setContent(“[url]www.xyz.net”[/url], “text/plain”);
    setText() method can also be used to set the content.
    Java Code:
    Message.setText(“[url]www.xyz.net”);[/url]
    ...
    Categories
    Mail API
  9. Java Mail API Session

    by , 04-25-2012 at 09:49 PM
    Top leveled entry class that presents mailing session is known as session. java.util.Properties object is used for seeking information regarding username/password and mail server. Private constructor is present in this class and session objects can be obtained via getDefaultInstance() & getInstance() method. The default session object are provided by the getDefaultInstance() method where authenticator objects and properties are taken as arguments.

    Java Code:
    Properties props = new
    ...
    Categories
    Mail API
  10. Apache Mail server (James)

    by , 04-25-2012 at 09:48 PM
    This section will discuss the James mail server. James is a portable and complete enterprise mailing server and a mailing app platform. Its latest version is found to be 2.3.1
    Mailet API

    This is basically a Java API which comes along James Mailing server. Developers are supported by it to develop mailing processing app quickly so that enterprise mailing problems could be solved. Flexible solutions for mail processing can be developed very easily and be deployed in production. ...
    Categories
    Mail API
  11. Mailing protocols

    by , 04-25-2012 at 09:47 PM
    Standard methods are presented by a protocol used at every communication channel’s end so that the information could be transmitted properly.

    Four protocols send/receive Emails.

    (Simple Mail Transfer Protocol) SMTP: Email is delivered by SMTP to the mailing server of recipient. Communication is done by the Java mail applications with the ISP SMTP servers of user or company. SMTP servers send messages to the SMTP server of the recipient.

    (Post Office Protocol ...
    Categories
    Mail API
  12. How does Email works

    by , 04-25-2012 at 09:42 PM
    Every DOMAIN consists of mailing server, when an email is sent by a user.

    1. Message is sent by email client program to the email server.
    2. Email server of recipient is contacted by the email server
    3. Validity of username is checked by the email server.
    4. If username is valid, email is sent to the email server of the address.
    5. When recipient signs in to his mailing account, he finds his email.

    Name:  1.jpg
Views: 4668
Size:  21.6 KB
    ...
    Categories
    Mail API
  13. Introduction to Java Mail API

    by , 04-25-2012 at 09:39 PM
    Java Mail API provides an opportunity to the developers to do the additional functionalities of email, to the java app. This section details the introduction of the Java Mail API.
    A platform independent sort of framework is provided by the Java Mail API so that messaging & mail applications could be developed in Java technologies. This is protocol independent which makes it much more beneficial. Various protocols could be used to work with messages and mails.
    Java Mail API provides ...
    Categories
    Mail API
  14. Sending Mail with Attachments

    by , 04-25-2012 at 09:37 PM
    There could be no or more than one file attachments present with an outgoing message.
    File data and file name is present with an attachment. File data may be extracted from some source like data store or application data file. Attachment’s MIME type is determined by the filename.

    Below is given MIME types list and also their file name extensions which are permitted for the attachments, to an email. You are not just bound to such extensions. If an unknown extension is used, ...
  15. Receiving Mail

    by , 04-25-2012 at 09:36 PM
    Email could be received by your application at such kind of addresses.

    string@appid.appspotmail.com

    It shall be noted that even application gets deployed at the customized domain, application couldn’t get the mail that has been sent to those addresses which are present at that domain.

    To applications, email messages are being sent as HTTP requests. Such requests are basically generated by the help of app Engine and are being posted to the applications. ...
    Categories
    Mail Message
  16. Email Multi-Part Messages

    by , 04-25-2012 at 09:33 PM
    Message could be sent with text, HTML message body or file attachment by using multi part messages. MimeMultipart object can be created to hold parts, then MimeBodyPart objects are created for every attachment/ message body and added to container. Lastly, container is assigned to MimeMessage content.

    Java Code:
    import javax.activation.DataHandler;
    import javax.mail.Multipart;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMultipart;
    ...
  17. Email Senders and Recipients

    by , 04-25-2012 at 09:31 PM
    Recipient and sender of email addresses are presented in JavaMail, by InternetAddress class instances. Email addresses are taken by the constructor as a string, & AddressException are raised when there is no resemblance b/w valid email address and address. Personal name is provided as a string, for 2nd parameter.
    Sender address could be set by calling setForm() method, at MimeMessage object. Sender address has these given types:
    • Registered administration’s address, for application.
    • User’s
    ...
  18. Sending Email Messages

    by , 04-25-2012 at 09:28 PM
    A MimeMessage object is prepared by an application so that to send email. Email is sent along with static method send(), on Transport class. JavaMail session object is used to create the message. Transport and session work along with App Engine Mail service, with no extra configuration.

    import java.util.Properties;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.AddressException; ...
    Categories
    Mail Message
  19. How to get e-mail with Java

    by , 02-29-2012 at 03:39 PM
    In the article “How to send e-mail with Java”, you are familiar with the JavaMail API on sending e-mail messages from a SMTP server. What about receiving e-mail messages? Well, that is the topic of this article. We will study how the JavaMail API exposes classes and interfaces for retrieving e-mail messages from a server, to write a utility class that checks for new messages in inbox of an e-mail account from Gmail server.

    Protocols for receiving e-mail

    There are two ...
    Categories
    Mail API
  20. How to send e-mail with Java

    by , 02-29-2012 at 03:05 PM
    Sending an e-mail is a trivial task in the information world today. Billions of e-mails are sent everyday on the earth. For those who are Java developers, the ability to send e-mail from within a Java program is trivial also. However the standard Java platform does not include any e-mail functionality by default. Instead, developers have to use a separate library for the e-mail things, it is the JavaMail API. This article will guide you on how to write an email utility to send an e-mail out with ...
    Tags: java, javamail, mail, send Add / Edit Tags
    Categories
    Mail API