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

번호 제목 글쓴이 날짜 조회 수
271 [HttpURLConnection, HttpsURLConnection] 코드참조용 샘플프로젝트 secret 황제낙엽 2019.01.18 0
270 Iterator.next() - NoSuchElementException 황제낙엽 2018.10.28 344
269 OracleJDK 유료화 FAQ (Oracle Java 의 유료화에 대한 어느분의 정리) 황제낙엽 2018.10.11 128
268 메일서버(daum.net)에 POP3를 이용하여 메일 가져오기 예제 file 황제낙엽 2018.10.09 940
» Sending mail through Java using SMTP of gmail file 황제낙엽 2018.09.13 163
266 Read or get mails using pop in java (using gmail) file 황제낙엽 2018.09.13 861
265 Collections.sort() , Comparator 황제낙엽 2018.08.23 48
264 JavaMail - Connecting Gmail pop3 server. 황제낙엽 2018.08.20 206
263 JavaMail - 네이버 메일 수신하기(POP3) 황제낙엽 2018.08.20 1413
262 JavaMail - POP3로 메일 읽어오기 - 단순샘플 황제낙엽 2018.08.20 107
261 [HttpURLConnection, HttpsURLConnection] Response 로 받은 데이터가 압축되어 있는 경우(gzip, deflate) 황제낙엽 2018.08.16 254
260 [HttpURLConnection, HttpsURLConnection] 자바 Http / https 의 결과를 주고받을때 세션을 유지 황제낙엽 2018.08.12 77
259 [HttpURLConnection] 자바(Java) URL 접속 및 세션 관리 file 황제낙엽 2018.08.12 109
258 json-rpc 에서 한글 문제 황제낙엽 2018.08.08 175
257 org.apache.commons.io.FilenameUtils (getExtension) 황제낙엽 2018.04.01 1209
256 이미지 파일의 화면사이즈와 포맷(확장자) 구하기 황제낙엽 2018.04.01 472
255 File 을 다루기 위한 유틸 클래스 file 황제낙엽 2018.02.28 99
254 상수의 데이터 타입 황제낙엽 2018.01.26 33
253 Java에서 User-Agent 파써 사용하기 황제낙엽 2017.11.20 418
252 현재 월,일,시간,분,초 등등 가져오기 황제낙엽 2017.11.02 858