javamail邮件开发入门(1)
简单的邮件发送:
public static void main(String[] args) throws UnsupportedEncodingException, AddressException { Properties props = new Properties(); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.auth ", "true"); Session session = Session.getInstance(props, null); session.setDebug(true); try { Transport transport = session.getTransport(); transport.connect("smtp.qq.com", "10086@qq.com", "888888"); MimeMessage msg = new MimeMessage(session); msg.setFrom(InternetAddress.parse(""yonge.gao"<10086@qq.com>")[0]); //msg.setRecipients(Message.RecipientType.TO, "10086@qq.com,10010@qq.com"); msg.setSubject(MimeUtility.decodeText("第二次实验")); msg.setSentDate(new Date()); msg.setText("Hello, World!\n"); transport.sendMessage(msg, InternetAddress.parse("10086@sohu.com")); transport.close(); } catch (MessagingException mex) { System.out.println("send failed, exception: " + mex); } }?