我如何使用hotmail帐户从javamail发送邮件 [英] how can i send mail from javamail using hotmail account
问题描述
我尝试了这种编码,
i tried this coding,,
<%@page import ="java.sql.*" %>
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.mail.internet.*,javax.activation.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%
String host ="smtp.live.com";
String from ="my hotmail email id";
String to ="receiver mail id";
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
Session msession = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(msession);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
// Send message
Transport.send(message);
%>
但是我得到了如下所示的错误..
类型例外报告
留言
描述服务器遇到内部错误(),导致服务器无法满足此请求.
例外
javax.servlet.ServletException:javax.mail.AuthenticationFailedException:连接失败,未指定密码?
根本原因
javax.mail.AuthenticationFailedException:连接失败,未指定密码?
note可以在GlassFish v3日志中找到该异常及其原因的完整堆栈跟踪.
But i got error as shown below..
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.mail.AuthenticationFailedException: failed to connect, no password specified?
root cause
javax.mail.AuthenticationFailedException: failed to connect, no password specified?
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.
推荐答案
请参见JavaMail API [ ^ ].试试看,当您遇到更具体的问题时,请返回此处,获得更多详细信息.
See the documentation for JavaMail API[^]. Give it a try and when you have a more specific problem come back here with some more detail.
^ ]
通过Java电子邮件 [ http://www.hmailserver.com/ [ ^ ]是免费且易于使用的.请注意,此服务还具有自动禁止功能-> 设置"-> 高级"
jGuru: Fundamentals of the JavaMail API[^]
E-Mailing Through Java[^]
You might want to read both. Also please use a local emailserver on your machine for testing. Most real pop3 servers are only allowing a couple of contacts each 15 min.
http://www.hmailserver.com/[^] is free and easy to use. Please be aware that also this service has an auto-ban function -> "Settings" -> "Advanced"
这篇关于我如何使用hotmail帐户从javamail发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!