Oct 01

Use JavaMail API


// Create session
    
Properties sessionProperties = System.getProperties();
sessionProperties.put("mail.smtp.host", smtpServer);
Session session = 
   Session.getDefaultInstance(sessionProperties, null);
    
// Create message
    
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, 
   InternetAddress.parse(to, false));
message.setSubject(subject);
message.setText(body);

// Send the message

Transport.send(message); 

written by objects \\ tags: , ,


Leave a Reply

You must be logged in to post a comment.