Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void sendMessage(String fromAddress, String toAddress, String emailSubject, String emailBody) throws AddressException,
- MessagingException {
- Properties props = System.getProperties();
- props.put("mail.smtp.host", "localhost");
- Session session = Session.getDefaultInstance(props, null);
- Message msg = new MimeMessage(session);
- msg.setFrom(new InternetAddress(fromAddress));
- msg.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(toAddress, false));
- msg.setSubject(emailSubject);
- msg.setText(emailBody);
- Transport.send(msg);
- }
Add Comment
Please, Sign In to add comment