使用JavaMail编程,使用新浪的服务器发送邮件,结果提示错误如下:
DEBUG: setDebug: JavaMail version 1.4.3
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.sina.com", port 25, isSSL false
220 irxd5-203.sinamail.sina.com.cn ESMTP
DEBUG SMTP: connected to host "smtp.sina.com", port: 25EHLO
501 #5.0.0 EHLO requires domain address
HELO
250 irxd5-203.sinamail.sina.com.cn
DEBUG SMTP: use8bit false
MAIL FROM:<[email protected]>
530 Authentication required
DEBUG SMTP: got response code 530, with response: 530 Authentication requiredRSET
250 reset各位大虾帮帮我
DEBUG: setDebug: JavaMail version 1.4.3
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.sina.com", port 25, isSSL false
220 irxd5-203.sinamail.sina.com.cn ESMTP
DEBUG SMTP: connected to host "smtp.sina.com", port: 25EHLO
501 #5.0.0 EHLO requires domain address
HELO
250 irxd5-203.sinamail.sina.com.cn
DEBUG SMTP: use8bit false
MAIL FROM:<[email protected]>
530 Authentication required
DEBUG SMTP: got response code 530, with response: 530 Authentication requiredRSET
250 reset各位大虾帮帮我
解决方案 »
- 有人能详细说说jsp里request和response的作用吗??
- request在超链接中失效的问题
- jsp中文章格式化输出的问题
- 如何快速检测到应用中哪里有内存泄露?
- 问个简单的问题
- struts+spring+hibernate如何实现原生态的SQL语句查询?急!!
- jsp发布的问题
- 高分相求超级幼稚问题(弱,弱,弱)
- 我的页面源代码如下,请各位帮我加一个分页显示和奇偶数行不通颜色显示我不能实现谢谢
- 为什么菜单显示不完,如何解决,大神指点
- hibernate session API的一些疑问
- 调用oracle函数出错:java.sql.SQLException: 索引中丢失 IN 或 OUT 参数:: 1
你可以通过用telnet 试下看能不能telnet到 smtp服务器上,
在看看你的25端口是否被屏蔽掉,你电脑上或者局域网上===
* 必须将mail.smtp.auth属性设置为true,SMTPTransport对象才会向
* SMTP服务器提交用户认证信息,这个信息可以从JavaMail的javadocs文档
* 中的com.sun.mail.smtp包的帮助页面内查看到。
*/ props.setProperty("mail.smtp.auth", "true");创建session对象的时候 properties !先测试是否能连接到服务器的 smtpServer !如果能连上了,应该没有问题了。边不上。查看上面的地方。!1: 连接时参数有没少
2: 有没有设好props.setProperty("mail.smtp.auth", "true");
差不多了。
<%@ page language="java" import="java.util.*,javax.mail.internet.*,javax.mail.*" pageEncoding="GB18030"%>
<%request.setCharacterEncoding("gbk"); %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>发送邮件结果</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<%
try{
String to_mail = request.getParameter("to");
String to_title = request.getParameter("title");
String to_content = request.getParameter("content");
//建立邮件会话
Properties props = new Properties();//也可用Properties props = System.getProperties();
props.put("mail.smtp.host","smtp.sina.com");//存储发送邮件服务器的信息
props.put("mail.smtp.auth","true");//同时通过验证
Session s = Session.getDefaultInstance(props);//根据属性新建一个邮件会话
s.setDebug(true);
//由邮件会话新建一个消息对象
MimeMessage message = new MimeMessage(s);//由邮件会话新建一个消息对象
//设置邮件
InternetAddress from = new InternetAddress("[email protected]");
message.setFrom(from);//设置发件人
InternetAddress to = new InternetAddress(to_mail);
message.setRecipient(Message.RecipientType.TO,to);//设置收件人,并设置其接收类型为TO
message.setSubject(to_title);//设置主题
message.setText(to_content);//设置信件内容
message.setSentDate(new Date());//设置发信时间
//发送邮件
message.saveChanges();//存储邮件信息
Transport transport = s.getTransport("smtp");
//以smtp方式登录邮箱,第一个参数是发送邮件用的邮件服务器SMTP地址,第二个参数为用户名,第三个参数为密码
transport.connect("smtp.sina.com","tougao","8807693");
transport.sendMessage(message,message.getAllRecipients());//发送邮件,其中第二个参数是所有已设好的收件人地址
transport.close();
%>
<div align="center">
<p>发送成功!</p>
</div>
<%
}catch(MessagingException e){
out.println("发送失败!");
}
%>
</body>
</html>
新浪的POP3和SMTP功能都开通了,可还是不行啊