MailUtils
Utility methods to send a mail. For example to send message or send document.
Methods
Section titled “Methods”sendMessage
Section titled “sendMessage”Description:
| Method | Return values | Description |
|---|---|---|
| sendMessage(String toAddress, String subject, String content) | void | Send mail without FROM addresses. |
- toAddress: The destination addresses for mail.
- subject: The mail subject.
- content: The mail body.
Example:
package com.openkm;
import com.openkm.util.MailUtils;
public class Test { public static void main(String[] args) { try { MailUtils.sendMessage("noreply@openkm.com", "this is the subject", "This is the text"); } catch (Exception e) { e.printStackTrace(); } }}sendMessage
Section titled “sendMessage”Description:
| Method | Return values | Description |
|---|---|---|
| sendMessage(String fromAddress, String toAddress, String subject, String content) | void | Send mail with FROM addresses. |
- fromAddress: The from addresses for mail.
- toAddress: The destination addresses for mail.
- subject: The mail subject.
- content: The mail body.
Example:
package com.openkm;
import com.openkm.util.MailUtils;
public class Test { public static void main(String[] args) { try { MailUtils.sendMessage("from_noreply@openkm.com", "to_noreply@openkm.com", "this is the subject", "This is the text"); } catch (Exception e) { e.printStackTrace(); } }}sendDocuments
Section titled “sendDocuments”Description:
| Method | Return values | Description |
|---|---|---|
| sendDocuments(String fromAddress, List |
MimeMessage | Send document to non-registered OpenKM users. |
- fromAddress: The from addresses for mail.
- toAddress: The list of destination addresses for mail.
- subject: The mail subject.
- text: The mail body.
- docsPath: The path of the documents to be send.
Example:
package com.openkm;
import java.util.ArrayList;import java.util.List;
import com.openkm.util.MailUtils;
public class Test { public static void main(String[] args) { try { List<String> docsPath = new ArrayList<>(); List<String> listAddress = new ArrayList<>(); listAddress.add("to_noreply@openkm.com"); docsPath.add("/home/openkm/test.png"); docsPath.add("/home/openkm/test2.png"); docsPath.add("/home/openkm/test3.png"); MailUtils.sendDocuments("from_noreply@openkm.com", listAddress, "this is the subject", "This is the text", docsPath); } catch (Exception e) { e.printStackTrace(); } }}