Tag: JavaMail
String to = "..." String from = "..." Properties prop = new Properties(); prop.put("mail.smtp.host", "127.0.0.1"); Session session = Session.getInstance(prop, null); try { MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] addresses = { new InternetAddress(to) }; msg.setRecipients(Message.RecipientType.TO, addresses); msg.setSentDate(new Date()); msg.setSubject(subject, "iso-2022-jp"); msg.setText(message, "iso-2022-jp"); msg.setHeader("Content-Type", "text/plain; charset=iso-2022-jp"); msg.setHeader("Content-Transfer-Encoding", "7bit"); Transport.send(msg); } catch (Exception ex) { ex.printStackTrace(); }