Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package database;
- import com.sun.xml.internal.bind.v2.runtime.reflect.Lister;
- import io.netty.channel.ChannelHandlerContext;
- import network.Handler;
- import packet.Packet;
- import java.util.List;
- import java.util.Properties;
- import javax.mail.Address;
- import javax.mail.Authenticator;
- import javax.mail.Message;
- import javax.mail.PasswordAuthentication;
- import javax.mail.Session;
- import javax.mail.Transport;
- import javax.mail.internet.InternetAddress;
- import javax.mail.internet.MimeMessage;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- * Created by ksy98_000 on 2016-12-30.
- */
- public class Mail {
- final private String username = "indizss99@gmail.com";
- final private String password = "tnddusdl12";
- private static Logger logger = Logger.getLogger(Handler.class.getName());
- public void sendmail(ChannelHandlerContext ctx, String email, String _password){
- Properties props = new Properties();
- props.put("mail.smtp.host", "smtp.gmail.com");
- props.put("mail.smtp.port", "25");
- props.put("mail.debug", "false");
- props.put("mail.smtp.auth", "true");
- props.put("mail.smtp.starttls.enable","true");
- props.put("mail.smtp.EnableSSL.enable","true");
- props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
- props.setProperty("mail.smtp.socketFactory.fallback", "false");
- props.setProperty("mail.smtp.port", "465");
- props.setProperty("mail.smtp.socketFactory.port", "465");
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password);
- }});
- try{
- Message message = new MimeMessage(session);
- message.setFrom(new InternetAddress("indizss99@gmail.com"));//
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse(email));
- message.setSubject("시나브로 온라인 비밀번호 찾기");
- message.setText("시나브로 온라인 비밀번호 찾기 결과입니다."
- + "\n\n 회원님의 비밀번호는 [ " + _password + " ] 입니다." + "\n감사합니다.");
- Transport.send(message);
- logger.log(Level.INFO, "이메일 " + email + " 님에게 비밀번호 찾기용 메일이 전송되었습니다.");
- ctx.writeAndFlush(Packet.loginMessage(3));
- } catch(Exception e){
- e.printStackTrace();
- ctx.writeAndFlush(Packet.loginMessage(4));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement