标题:javamail的问题[求助]好奇怪哦
只看楼主
siruyi
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-10-15
 问题点数:0 回复次数:6 
javamail的问题[求助]好奇怪哦

请大家帮忙看哈,

错在那里 我用的是tomcat
当写到/*(红色)的时候还是对的,,下去一行写

Mimemassage the Message = new MimeMessage(theSession);

这时候就错了,提示:

The server encountered an internal error () that prevented it from fulfilling this request.


难道是怪mail.jar没配置好吗?也不应该啊,Session都能用啊,请大家帮忙啊 都快哭了


<%@page contentType="text/html"%>
<%@page pageEncoding = "GB2312"%>
<%@page import = "java.util.*,java.io.*"%>
<%@page import = "javax.mail.*"%>

<%@page import = "javax.mail.internet.*"%>
<%@page import = "javax.activation.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> mail </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<%
Properties theProperties = System.getProperties();
theProperties.put("mail.host","127.0.0.1");
theProperties.put("mail.transport.protocol","smtp");

out.println("234234tTGSDG5");
Session theSession =
Session.getDefaultInstance(theProperties,null);
theSession.setDebug(false);


MimeMessage theMessage = new MimeMessage(theSession);/*
theMessage.setFrom(new InternetAddress("coffee@fj.com"));/*

theMessage.setRecipients(Message.RecipientType.TO,"35033734@qq.com");
theMessage.setSubject("JavaMail");
theMessage.setText("看哈通了没有","GB2312");

Transport.send(theMessage);
out.println("发送成功");*/


%>
daodidf
</BODY>
</HTML>



[此贴子已经被作者于2007-4-2 12:55:57编辑过]

搜索更多相关主题的帖子: javamail The target page 
2007-04-02 12:32
siruyi
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-10-15
得分:0 
大家一定要帮我啊,,我代表我自己谢谢你们了先

2007-04-02 12:35
siruyi
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-10-15
得分:0 
真的没有人肯帮忙解决一下吗?








2007-04-02 12:47
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 
不是说了第34行有异常吗
你检查一下吧

可惜不是你,陪我到最后
2007-04-02 13:23
支离破碎
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:737
专家分:0
注 册:2007-1-4
得分:0 
建议你在JAVA中去写一个来用debug调试,用JSP太难调试了。

人生漂泊無依,有如浮萍菱花,隨水飄流,你会在我这里停留吗?
[url=http://51mynet.]http://51mynet.[/url]
2007-04-02 13:27
黄袖标
Rank: 4
等 级:贵宾
威 望:13
帖 子:676
专家分:0
注 册:2007-3-22
得分:0 

楼主,其实呢,很多问题还是靠自己的。
其实你完全可以自己搞定n多东西。靠自己才是硬道理。

javamail使用笔记
本文描述了3个常见的javamail问题,至于其它问题可以看javamail的例子
1:怎样发送认证邮件

不想以前那样,很多smtp服务器已经不能随便让你通过它发信,你必须提供用户名和密码才能发信,下面的示例演示了这样的一种情况。


import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailExample {
public static void main (String args[]) throws Exception ,MessagingException{
String host = "smtp.263.net";
String from = "zong_feng@263.net";
String to = "zfvc@163.com";


// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", host);

props.put("mail.smtp.auth","true");

// Get session
Session session = Session.getDefaultInstance(props, null);

// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
message.saveChanges();

// Send message
Transport transport = session.getTransport("smtp");
transport.connect(host, "zong_feng","111111");
transport.sendMessage(message, message.getAllRecipients());
}
}


2:发送附件

import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class sendfile {

public static void main(String[] args) {


String to = "zfvc@163.com";
String from = "zong_feng@263.net";
String host = "smtp.263.net";
String filename = args[0];
//boolean debug = Boolean.valueOf(args[4]).booleanValue();
String msgText1 = "宗锋.n";
String subject = "Sending a file";

// create some properties and get the default Session
Properties props = System.getProperties();
props.put("mail.smtp.host", host);

props.put("mail.smtp.auth","true");

Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);

try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);

// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(msgText1);

// create the second message part
MimeBodyPart mbp2 = new MimeBodyPart();

// attach the file to the message
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());

// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);

// add the Multipart to the message
msg.setContent(mp);

// set the Date: header
msg.setSentDate(new Date());

// send the message

Transport transport = session.getTransport("smtp");
transport.connect(host, "zong_feng","dsf");
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
} catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}
}
}
}


3:怎样是IMAP和POP3一起工作

Use different session objects (don't use the default). Get the session with Session.getInstance() instead of getDefaultInstance().


我胡汉三又回来啦!物是人非啊,只有静夜思大大还在。
2007-04-02 17:35
黄袖标
Rank: 4
等 级:贵宾
威 望:13
帖 子:676
专家分:0
注 册:2007-3-22
得分:0 
我也是从网上找的,我相信你也可以,多动手,主动一点。很多问题也就不成为问题了,说明下,上面的文章是转的,偶可是从来不冒充原创嘀

我胡汉三又回来啦!物是人非啊,只有静夜思大大还在。
2007-04-02 17:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-128628-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.128101 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved