如何将我通过javamail编写的消息存储到MySQL表中?我已经配置了james服务器配置文件以连接到MySQL服务器(使用数据源元素名称maildb),并且我将James服务器配置文件中的<inboxRepository>元素更改为
<inboxRepository>
<repository destinationURL="db://maildb/spammer/"
type="MAIL"/>
</inboxRepository>但我仍然无法读取MySql邮件数据库中垃圾邮件发送者表的收件箱列中的消息。
下面是我的javamail类:
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class mail{
public static void main(String[] argts){
String to = "red@localhost";
String from = "blue@localhost";
String subject = "jdk";
String body = "Down to wind";
if ((from != null) && (to != null)
&& (subject != null) && (body != null))
// we have mail to send
{
try {
Properties props = new Properties();
props.put("mail.host", "127.0.0.1 ");
props.put("mail.smtp.auth","true");
Session session =
Session.getInstance(props, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("blue", "blue");
}
});
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
Address[] add={ new InternetAddress(to) };
message.setRecipients(Message.RecipientType.TO,add);
message.setSubject(subject);
message.setContent(body, "text/plain");
message.setText(body);
Transport.send(message);
System.out.println
("<b>Thank you. Your message to "+to+" was successfully sent.</b>");
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}我在这里做错了什么,我如何从MySQL中的垃圾邮件发送者表中读取邮件?
发布于 2011-07-13 20:32:27
也许你使用了错误的数据库地址: destinationURL="db://maildb/spammer/“I propose change to destinationURL=" mysql ://maildb/spammer/”如果目标当然是mysql数据库的话。
https://stackoverflow.com/questions/1514908
复制相似问题