sorry,看错了,你可以用sohu的免费信箱。smtp.sohu.com
解决方案 »
- 如何在外部修改web项目的context-root(web发布名称)
- 在tomcat运行状态下,电脑突然断电,结果通过jsp上传的文件丢失!为什么会这样?
- 一个月内要做OA的需求分析,2天后要提交这个月的甘特图
- 第一次配置tomcat,并运行第一个JSP,出现错误,请帮帮忙
- easy!
- 一个html页面通过button来增加节点a,在线等
- 关于用String.getBytes("ISO-8859-1")进行中文处理的问题
- 各位:求救,为什么我的Jbuilder运行jsp时提示出现如下错误?如何解决?
- 有什么javabean实现二维与三维图表的
- httpservletrequest.getparameter接收类似%1xx会出现转码情况
- 第一次遇到这样的排序问题!!!!
- 请问为什么文本框输入为空时不提示信息阿?我脚本里写了呀!谢谢!
我怀疑你没有加入认证的代码。
pop3.sohu.com
smtp.sohu.com
可是不行啊!
<%@ page import="javax.mail.*,javax.mail.internet.*,javax.activation.*,java.util.*"%>
<HTML>
<HEAD>
<TITLE>JavaMail电子邮件发送系统</TITLE>
</HEAD>
<BODY>
<%
try{
Properties props=new Properties();
Transport transport;
props.put("mail.transport.protocol","smtp");
props.put("mail.smtp.host","smtp.sohu.com");
props.put("mail.smtp.auth","true");
Session mySession=Session.getInstance(props,new Authenticator(){
public PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("xxxxx","xxxxxxxxxx");
}
});
Message newMessage=new MimeMessage(mySession);
newMessage.setFrom(new InternetAddress("[email protected]"));
newMessage.setRecipient(Message.RecipientType.TO,new InternetAddress("[email protected]"));
newMessage.setSubject("title");//title
newMessage.setSentDate(new Date());//date
newMessage.setText("mail");//content
transport=mySession.getTransport("smtp");
transport.send(newMessage);
%>
<p>你的邮件已发送,请返回。</p>
<%
}
catch(MessagingException e)
{
out.println(e.toString());
}
%>
</BODY>
</HTML>