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

번호 제목 글쓴이 날짜 조회 수
283 수치 데이터 처리 유틸리티 file 황제낙엽 2019.05.12 1907
282 한글 초성 중성 종성 분리 유틸리티(자작) file 황제낙엽 2019.05.07 525
281 한글 초성 중성 종성 분리 (자모분리) 황제낙엽 2019.05.07 458
280 한글 인코딩의 이해 1편: 한글 인코딩의 역사와 유니코드 황제낙엽 2019.05.07 501
279 한글 인코딩의 이해 2편: 유니코드와 Java를 이용한 한글 처리 file 황제낙엽 2019.05.07 509
278 응답 헤더의 Content-disposition 속성 황제낙엽 2019.04.16 824
277 StringUtils - 문자열 처리 유틸리티 file 황제낙엽 2019.04.15 516
276 JSON과 GSON 황제낙엽 2019.03.24 594
275 File.length() 에 대하여 황제낙엽 2019.03.24 523
274 File.delete() 와 File.deleteOnExit() 황제낙엽 2019.03.24 2602
273 List to Array / Array to List 황제낙엽 2019.03.24 412
272 Oracle JAVA 유료화에 관련한 최신 기사 황제낙엽 2019.01.23 472
271 [HttpURLConnection, HttpsURLConnection] 코드참조용 샘플프로젝트 secret 황제낙엽 2019.01.18 0
270 Iterator.next() - NoSuchElementException 황제낙엽 2018.10.28 639
269 OracleJDK 유료화 FAQ (Oracle Java 의 유료화에 대한 어느분의 정리) 황제낙엽 2018.10.11 492
268 메일서버(daum.net)에 POP3를 이용하여 메일 가져오기 예제 file 황제낙엽 2018.10.09 1325
» Sending mail through Java using SMTP of gmail file 황제낙엽 2018.09.13 830
266 Read or get mails using pop in java (using gmail) file 황제낙엽 2018.09.13 11657
265 Collections.sort() , Comparator 황제낙엽 2018.08.23 556
264 JavaMail - Connecting Gmail pop3 server. 황제낙엽 2018.08.20 711