这段代码需要JavaMail支持
Properties props = new Properties(); props.put("mail.smtp.host", "your-smtp-host.com"); Session session = Session.getDefaultInstance(props, null); MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(to)); msg.setSubject(subject); msg.setSentDate(new Date()); msg.setContent(message, "text/plain"); Transport.send(msg);