sitelink1 http://www.nikhilnishchal.com/tech-blogs...p-of-gmail 
sitelink2  
sitelink3  
sitelink4  
sitelink5  
sitelink6  

Most of the case we required to send mail.
We can use gmail smtp to send the mail.
Code to send the mail are following.
Please update mailId and password:

package com.sendmail; 

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
/**
 * 
 * @author nikhil.nishchal
 *
 */
public class SendMailByGMAIL {

	//Properties for the SMTP configuration
    private static final String MAIL_SMTP_HOST = "smtp.gmail.com";
    private static final String MAIL_SMTP_PORT = "465";
    private static final String SOCKET_FACTORY = "javax.net.ssl.SSLSocketFactory"; 
    private static final String SMTP_AUTH = "true"; 
    private static final String SMTP_SOCKET_PORT = "465"; 
    private static final String SMTP_USER = "xxxxxx@gmail.com"; 
    private static final String SMTP_PASSWORD = "passwordText"; 
    private static final String MAIL_FROM_EMAIL_ID = "frommail@gmail.com"; 
    private static final String MAIL_TO_EMAIL_ID = "tomail@gmail.com"; 

	public static void main(String[] args) { 

		//Initialization of properties 
        Properties props = new Properties(); 
        props.put("mail.smtp.host", MAIL_SMTP_HOST); 
        props.put("mail.smtp.socketFactory.port", SMTP_SOCKET_PORT); 
        props.put("mail.smtp.socketFactory.class", SOCKET_FACTORY); 
        props.put("mail.smtp.auth", SMTP_AUTH); 
        props.put("mail.smtp.port", MAIL_SMTP_PORT); 

         //Making authentication session 
        Session session = Session.getDefaultInstance(props, 
                new javax.mail.Authenticator() { 
                    protected PasswordAuthentication getPasswordAuthentication() { 
                        return new PasswordAuthentication(SMTP_USER, 
                                SMTP_PASSWORD); 
                    } 
                }); 

         try { 
            System.out.println("Sending mail..."); 
            Message message = new MimeMessage(session); 
            message.setFrom(new InternetAddress(MAIL_FROM_EMAIL_ID)); 
            message.setRecipients(Message.RecipientType.TO, 
                    InternetAddress.parse(MAIL_TO_EMAIL_ID)); 
            message.setSubject("Test Mail Subject"); 
            message.setText("Dear Friend," 
                    + "\n\n This is spam free mail, enjoy the text." 
                    + "\n\n\n\n Thanks"); 

           System.out.println("Mail has been sent..."); 

         } catch (MessagingException e) { 
            System.out.println("Exception:\n"+e.getMessage()); 
        } 
    } 
} 

For this, you need Java mail API.
Java mail API we can download from http://www.oracle.com/technetwork/java/javamail/index-138643.html

번호 제목 글쓴이 날짜 조회 수
266 한글 인코딩의 이해 2편: 유니코드와 Java를 이용한 한글 처리 file 황제낙엽 2019.05.07 822
265 응답 헤더의 Content-disposition 속성 황제낙엽 2019.04.16 1047
264 StringUtils - 문자열 처리 유틸리티 file 황제낙엽 2019.04.15 660
263 File.length() 에 대하여 황제낙엽 2019.03.24 909
262 File.delete() 와 File.deleteOnExit() 황제낙엽 2019.03.24 3074
261 List to Array / Array to List 황제낙엽 2019.03.24 574
260 Oracle JAVA 유료화에 관련한 최신 기사 황제낙엽 2019.01.23 642
259 Iterator.next() - NoSuchElementException 황제낙엽 2018.10.28 801
258 OracleJDK 유료화 FAQ (Oracle Java 의 유료화에 대한 어느분의 정리) 황제낙엽 2018.10.11 659
257 메일서버(daum.net)에 POP3를 이용하여 메일 가져오기 예제 file 황제낙엽 2018.10.09 1607
» Sending mail through Java using SMTP of gmail file 황제낙엽 2018.09.13 1084
255 Read or get mails using pop in java (using gmail) file 황제낙엽 2018.09.13 11924
254 Collections.sort() , Comparator 황제낙엽 2018.08.23 746
253 JavaMail - Connecting Gmail pop3 server. 황제낙엽 2018.08.20 1170
252 JavaMail - 네이버 메일 수신하기(POP3) 황제낙엽 2018.08.20 1793
251 JavaMail - POP3로 메일 읽어오기 - 단순샘플 황제낙엽 2018.08.20 717
250 [HttpURLConnection, HttpsURLConnection] Response 로 받은 데이터가 압축되어 있는 경우(gzip, deflate) 황제낙엽 2018.08.16 890
249 [HttpURLConnection, HttpsURLConnection] 자바 Http / https 의 결과를 주고받을때 세션을 유지 황제낙엽 2018.08.12 801
248 [HttpURLConnection] 자바(Java) URL 접속 및 세션 관리 file 황제낙엽 2018.08.12 775
247 org.apache.commons.io.FilenameUtils (getExtension) 황제낙엽 2018.04.01 1886