<%@ page import= " javax.mail.*, javax.mail.internet.*, javax.activation.*, java.util.*"%><html>
<head>
<title> JavaMail 电子邮件发送系统 </title></head>
<body>
<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;
sendMailSession = Session.getInstance(props, null);
props.put("mail.smtp.host", "smtp.sohu.com");
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress(request.getParameter("from")));
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(request.getParameter("to")));
newMessage.setSubject(request.getParameter("subject"));
newMessage.setSentDate(new Date());
newMessage.setText(request.getParameter("text"));
transport = sendMailSession.getTransport("smtp");
transport.connect("smtp.sohu.com","wang76_cn","764688");
transport.send(newMessage);
%>
<p> 你的邮件已发送,请返回。 <p>
<%
}
catch(MessagingException m)
{
out.println(m.toString());
}
%>
</body>
</html>我从表单中提交form: [email protected]
to: [email protected]
怎么出错呀: javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: 505 Client was not authenticated
解决方案 »
- eclipse下边写了新包和新类,eclipse工作台下class包里没有新包和新类
- Struts + Spring 整合问题
- 小弟有一事想问,我在JS中定义了一个list,如何提交给action或后台?
- 急!
- (上传问题)java.lang.StringIndexOutOfBoundsException: String index out of range: -63657
- 关于枚举类型(高手解决)高分!!
- jsp和sql数据库连接~~~
- ActionForm封装数据的问题
- 求救!!请高手帮忙,解决问题立即给你,多谢!
- 有谁遇见这样的问题:上传问题,Malformed form data!在线等,50分
- 高手吗?介绍一下source code control system,such as CVS
- httpd,jhtml,shtml都是什么呢?
<%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>
<%
String e_smtp=request.getParameter("smtp");
String e_from=request.getParameter("from");
String e_to=request.getParameter("to");
String e_subject=request.getParameter("subject");
String e_body=request.getParameter("body"); try{
SmtpClient client = new SmtpClient(e_smtp);
client.from(e_from);
client.to(e_to);
PrintStream message = client.startMessage();
message.println("To:" + e_to);
message.println("Subject:" + e_subject);
message.println(e_body);
message.println();
client.closeServer();
}
catch (IOException e){
System.out.println("EMAIL 发送出错:"+e);
}
out.println("--------------------------------发送成功--------------------------------<br>");
out.println("主题:" + e_subject);
out.println("<br>");
out.println("BODY:" + e_body);
%>
<%@ page language="java" import= " javax.mail.*, javax.mail.internet.*, javax.activation.*, java.util.*"%><html>
<head>
<title> JavaMail 电子邮件发送系统 </title></head>
<body>
<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;
sendMailSession = Session.getInstance(props, null);
props.put("mail.smtp.host", "202.96.44.20"); //"202.96.44.20" 是“smtp.263.net”的IP!
props.put("mail.smtp.auth", "true"); //add
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress("[email protected]"));
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
newMessage.setSubject("subject1");
newMessage.setSentDate(new Date());
newMessage.setText("text");
transport = sendMailSession.getTransport("smtp");
newMessage.saveChanges();
transport.connect("202.96.44.20","xz_zeng","password");
transport.sendMessage(newMessage,newMessage.getRecipients(Message.RecipientType.TO)); //modify
//transport.send(newMessage);
transport.close();
%>
<p> 你的邮件已发送,请返回。 <p>
<%
}
catch(SendFailedException e)
{
out.println(e.toString());
}
catch(MessagingException m)
{
out.println(m.toString());
}%>
</body>
</html> 还有啊,你把你263的密码改一下吧,哈哈。。!