java给qq邮箱发邮件!! javaqq邮箱 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 自己前面有些的 但老跑到 transport.connect(server, user, password);这个就不动了也不报错 你们给我个成功的例子 我测试下 看是不是腾讯封了我这个东西 public static void sendEmail(String email, String subject, String body) throws UnsupportedEncodingException { try { Properties props = new Properties(); props.put("mail.smtp.host", server); props.put("mail.smtp.auth", "true"); Transport transport = null; Session session = Session.getDefaultInstance(props); transport = session.getTransport("smtp"); transport.connect(server, user, password); MimeMessage msg = new MimeMessage(session); msg.setSentDate(new Date()); InternetAddress fromAddress = new InternetAddress(user, from, "UTF-8"); msg.setFrom(fromAddress); InternetAddress[] toAddress = new InternetAddress[1]; toAddress[0] = new InternetAddress(email); msg.setRecipients(Message.RecipientType.TO, toAddress); msg.setSubject(subject, "UTF-8"); msg.setText(body, "UTF-8"); msg.saveChanges(); transport.sendMessage(msg, msg.getAllRecipients()); } catch (NoSuchProviderException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); } } server是smtp服务器地址,user和password是用户名和密码,email是发给谁,subject主题,body内容,简单的文本邮件! 其实java email不是你发给谁。而是。你通过email api登录到哪个邮箱从那个邮箱发给谁。比如,你用java给自己的qq邮箱发邮件,其实是你自己登录了qq邮箱自己给自己发了一封邮件。 weblogic下struts标签问题,急>! 用JQuery实现文件的上传 MyEclipse启动Tomcat时错误 <s:if >点用 需帮忙!!! 用 URL 和 SSLSocket 访问 https 类型的网址出现不同结果! 谁能帮帮我 Hibernate创建数据库表无效 JBoss的下载地址 相同两个方法,上面那个就不报错,下面这个为什么就报错说变量可能未被初始化? 求助,请问如何改写才能不重复爬取具有相同url和sitename的网址 急!!!java访问webservice报401 项目连接分布式数据库之后,无法提交事务。求大神指点
public static void sendEmail(String email, String subject, String body)
throws UnsupportedEncodingException {
try {
Properties props = new Properties();
props.put("mail.smtp.host", server); props.put("mail.smtp.auth", "true");
Transport transport = null;
Session session = Session.getDefaultInstance(props);
transport = session.getTransport("smtp");
transport.connect(server, user, password);
MimeMessage msg = new MimeMessage(session);
msg.setSentDate(new Date());
InternetAddress fromAddress = new InternetAddress(user, from,
"UTF-8");
msg.setFrom(fromAddress);
InternetAddress[] toAddress = new InternetAddress[1];
toAddress[0] = new InternetAddress(email);
msg.setRecipients(Message.RecipientType.TO, toAddress);
msg.setSubject(subject, "UTF-8");
msg.setText(body, "UTF-8");
msg.saveChanges();
transport.sendMessage(msg, msg.getAllRecipients());
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
}
}
而是。你通过email api登录到哪个邮箱从那个邮箱发给谁。
比如,你用java给自己的qq邮箱发邮件,其实是你自己登录了qq邮箱自己给自己发了一封邮件。