我需要使用Java API在Apache James郵件服務器中添加新用戶,但是在整個互聯網中沒有任何關於如何使用它的示例。 只有這個http://james.apache.org/server/2.3.1/adding_users.html 用Java郵件API可以發送郵件到Apache James郵箱讀取郵件,但僅此。用java api在apache james中創建用戶帳戶
String user = "user"; // Newly created user on JAMES
String password = "user"; // user password
String fromAddress = "[email protected]"; // [email protected]
String toAddress = "[email protected]";
// Create a mail session
Properties properties = new Properties();
properties.put("mail.smtp.host", "localhost");
properties.put("mail.smtp.port", "25");
properties.put("mail.smtp.username", user);
properties.put("mail.smtp.password", password);
Session session = Session.getDefaultInstance(properties, null);
try
{
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromAddress));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toAddress));
message.setSubject("Email from our JAMES Server");
message.setText("Hello world again and again");
Transport.send(message);
System.out.println("Email sent successfully");
}
catch (MessagingException e)
{
e.printStackTrace();
}
有人知道或使用過James Java API嗎?任何例子?