Saturday, July 7, 2018

Email API facts

Note: please download given jar files in order to send email

In order to send email we need to download two jar files mail.jar and activation.jar. 

1. click here to download mail.jar

2. click here to download activation.jar

click on jar (joki red circle mai hai) when this file is downloaded please click on keep the file.







































* for sending email we are using smtp (simple mail transfer protocol)

* the smtp server will be smtp.gmail.com

* port number of this server is 587 

* To send email using java application are using mail.jar library

* In this jar files many classes are present those can be used to send an email

* list of classes are given below

1. Properties [this class will be used to provide the configuration information about the smtp server, like host-name, port number, transport layer security, and authentication information], this class is a part of JDK

2. Authenticator [this class is having a method named as getPasswordAuthentication(), from this method we will return the object of PasswordAuthentication class]

3. PasswordAuthentication [this class is used to authenticate the user who is sending email, for this we need to provide the email-id and password of the sender]

4. Session [this class is used to denote a session in which we send an email], object of Session can be fetched using getInstance() method, in this method we need to pass object of Properties, and object of subclass of Authenticator

5. MimeMessage [this class is used to denote the message that will be sent by the sender], object of 

6. InternetAddress [this class is used to denote the email-id of sender in the format which can be understand by the mail api]

7. Message [this class is used to denote receiver, those will get this email], this class uses RecipentType class in order to do its task]

8. MimeBodyPart [this class is used to denote the content of mail, like the text and attachment of email]

9. MimeMultipart [this class is used to store multiple body parts of mail as a single unit]

10. Transport [this class is actually used to send an email to the receiver], for this we call send() method of Transport class and pass object of Message class inside send() method


No comments:

Post a Comment