如何用JAVA实现本地发邮件,在线等待赐教 props.put("mail.smtp.auth", "true");加上它就要求认证了,你在连接的时候必须给出用户名和密码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Properties properties = System.getProperties(); properties.put("mail.smtp.host",smtp.sina.com); properties.put("mail.transport.protocol", "smtp"); properties.put("mail.smtp.auth","true"); Session session = Session.getInstance(properties, new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(strUserName,strPassword); } }); try { MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(strMail)); InternetAddress[] toadd = InternetAddress.parse(strEmailTo); message.setRecipients(Message.RecipientType.TO,toadd); Transport transport = session.getTransport(); message.saveChanges(); transport.send(message,message.getAllRecipients()); transport.close(); } catch (AddressException e) { } catch (SendFailedException e) { } catch (MessagingException e) { } 找点javamail方面的资料看看吧 java web通过jacob调用VC写的com组件,被调用函数的参数一直传不进去 怎么实现在一个表单中完成 2个onsubmit的方法 Axis2奇怪错误,求大虾们解答 如何将统计好的数字展示到jsp页面上? 奇怪的错误 springMVC hibernate commons-fileupload-1.2.1 struts2页面的显示问题 表单问题 jacob 操作word 在JBuilder9中显示中文问题 急急急,项目架构需要考虑的问题 servlet怎样输出Image型的数据?最好有代码实例 关于jsp的一个比较基本的问题,请各位提供点意见,谢谢!!
properties.put("mail.smtp.host",smtp.sina.com);
properties.put("mail.transport.protocol", "smtp");
properties.put("mail.smtp.auth","true");
Session session = Session.getInstance(properties,
new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(strUserName,strPassword);
}
});
try
{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(strMail));
InternetAddress[] toadd = InternetAddress.parse(strEmailTo);
message.setRecipients(Message.RecipientType.TO,toadd);
Transport transport = session.getTransport();
message.saveChanges();
transport.send(message,message.getAllRecipients());
transport.close(); }
catch (AddressException e)
{
}
catch (SendFailedException e)
{
}
catch (MessagingException e)
{
}