Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(action.equals("buy")){
- String to = (String)session.getAttribute("user");
- //Get the session object
- Properties props = new Properties();
- props.put("mail.smtp.host", "smtp.gmail.com");
- props.put("mail.smtp.socketFactory.port", "465");
- props.put("mail.smtp.socketFactory.class",
- "javax.net.ssl.SSLSocketFactory");
- props.put("mail.smtp.auth", "true");
- props.put("mail.smtp.port", "465");
- Session session2 = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication("henri.tuan77@gmail.com","Dumbledore77");//change accordingly
- }
- });
- //compose message
- try {
- MimeMessage message = new MimeMessage(session2);
- message.setFrom(new InternetAddress("henri.tuan77@gmail.com"));//change accordingly
- message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
- message.setSubject("Hello");
- message.setText("Testing.......");
- //send message
- Transport.send(message);
- System.out.println("message sent successfully");
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement