// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;

public class Email1 {
   private final static String SMTP_SERVER = "192.168.1.10";
   private final static String FROM = "arne@vajhoej.dk";
   public static void send(String to, String subj, String body) {
      try {
         Properties props = System.getProperties();
         props.put("mail.smtp.host", SMTP_SERVER);
         Session session = Session.getDefaultInstance(props, null);
         MimeMessage message = new MimeMessage(session);
         message.setFrom(new InternetAddress(FROM));
         message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
         message.setSubject(subj);
         message.setText(body);
         Transport.send(message);
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
   public static void main(String[] args) {
      send("arne_v@mail.danbbs.dk", "Test 1", "Linie 1\nLinie 2\nLinie 3\n");
   }
}
