Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void sendMail(/*String from,String to, String subject, String text*/) {
- String host = "smtp.naver.com";
- String user = "123123213@naver.com";
- String password = "123123123123";
- Properties prop = new Properties();
- prop.put("mail.smtp.host", "smtp.naver.com");
- prop.put("mail.smtp.port", 587);
- prop.put("mail.smtp.auth", "true");
- prop.put("mail.smtp.ssl.enable", "true");
- prop.put("mail.smtp.ssl.trust", "smtp.naver.com");
- Session session = Session.getDefaultInstance(prop, new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(user, password); }
- });
- try {
- MimeMessage message = new MimeMessage(session);
- message.setFrom(new InternetAddress(user));
- message.addRecipient(Message.RecipientType.TO, new InternetAddress("ktko@ktko.com"));
- // 메일 제목
- message.setSubject("KTKO SMTP TEST1111"); // 메일 내용
- message.setText("KTKO Success!!"); // send the message
- Transport.send(message);
- System.out.println("Success Message Send");
- }catch (MessagingException e) { e.printStackTrace(); System.out.println("에러"); }
- }
Add Comment
Please, Sign In to add comment