List of usage examples for javax.mail Transport send
public static void send(Message msg, String user, String password) throws MessagingException
From source file:atd.backend.Register.java
public void sendRegMail(Klant k) throws IOException { Properties propMail = new Properties(); InputStream config = null;//from ww w .ja va2 s . co m config = new URL(CONFIG_URL).openStream(); propMail.load(config); Properties props = new Properties(); props.put("mail.smtp.host", propMail.getProperty("host")); props.put("mail.smtp.port", 465); props.put("mail.smtp.ssl.enable", true); Session mailSession = Session.getInstance(props); try { Logger.getLogger("atd.log").info("Stuurt mail naar: " + k.getEmail()); MimeMessage msg = new MimeMessage(mailSession); msg.setFrom(new InternetAddress(propMail.getProperty("email"), propMail.getProperty("mailName"))); msg.setRecipients(Message.RecipientType.TO, k.getEmail()); msg.setSubject("Uw account is aangemaakt"); msg.setSentDate(Calendar.getInstance().getTime()); msg.setContent("Beste " + k.getNaam() + ", \n\nUw account " + k.getUsername() + " is aangemaakt, U kunt inloggen op de <a href='https://atd.plebian.nl'>ATD website</a>\n", "text/html; charset=utf-8"); // TODO: Heeft OAUTH nodig, maarja we zijn al niet erg netjes met // wachtwoorden Transport.send(msg, propMail.getProperty("email"), propMail.getProperty("password")); } catch (Exception e) { Logger.getLogger("atd.log").warning("send failed: " + e.getMessage()); } }