日期:2014-05-17 浏览次数:20654 次
public void sendMail(){ try{ Properties props=new Properties(); props.put("mail.smtp.host","0.0.0.0");//存储发送邮件服务器的信息 props.put("mail.smtp.auth","false");//同时通过验证 Session s=Session.getInstance(props); s.setDebug(true); MimeMessage message=new MimeMessage(s); message.setFrom(from); message.setRecipients(Message.RecipientType.TO, addresses); message.setRecipients(Message.RecipientType.CC, addressescc); message.setSubject(title);//设置主题 message.setContent(content,type);//设置信件内容 message.setSentDate(new Date());//设置发信时间 // 发送邮件 message.saveChanges(); Transport transport=s.getTransport("smtp"); transport.connect("0.0.0.0","",""); transport.sendMessage(message,message.getAllRecipients()); // 已设好的收件人地址 transport.close(); }catch(Exception e){ e.printStackTrace(); } }