This module is used for sending emails from Pnuts scripts. The Java Mail API is required to use this module.
sendEmail() sends an email. If a Map object is specified, the following keys are used.
Key Value mailhost String (if null, "localhost" is used instead) subject String content MimeMultipart, MimeBodyPart String, File, URL, or Array/Collection/Generator of those objects. charset String from String or InternetAddress to InternetAddress, String, or Array/Collection/Generator of those objects. cc InternetAddress, String, or Array/Collection/Generator of those objects. bcc InternetAddress, String, or Array/Collection/Generator of those objects. replyTo InternetAddress, String, or Array/Collection/Generator of those objects. userid String password String ssl boolean
sendEmail("mailhost", "subject", "Hello!", "myname", "friends")
m = map() m.mailhost = "foo.bar.com" m.subject = "test" m.from = "myname" m.to = "friends" m.content = "Hello!" sendEmail(m)
emailAddress() makes an InternetAddress object from address and optional personal_information. If personal_information includes any non-ASCII character, appropriate charset must be registerred with setMailCharset() before the emailAddress() call.
emailAddress("foo@bar.com", "whoever")
setMailCharset() registers the default charset for email content, subject, and personal information of email addresses.
mimepart() makes a MimeBodyPart object from content and mimeType.
html = mimepart("<html>...</html>", "text/html")
openMailStore() opens a mail store specifying a URL or a set of necessary information to open the store.
store = openMailStore("imap", "mailhost", "id", "pass")
openMailFolder() opens a mail folder.
folder = openMailFolder(store, "INBOX")
getMessages() creates an array of Message objects of the specified mail folder.
If fetchProfile is not null, the corresponding mail headers are prefetched.
The following variables are convenient when specifying the fetchProfile.
- FETCH_ENVELOPE
- From, To, Cc, Bcc, ReplyTo, Subject and Date. See FetchProfile$Item::ENVELOPE.
- FETCH_CONTENT_INFO
- ContentType, ContentDisposition, ContentDescription, Size and LineCount. See FetchProfile$Item::CONTENT_INFO.
- FETCH_FLAGS
- See FetchProfile$Item::FLAGS.
The default value of fetchProfile is [FETCH_FLAGS, FETCH_ENVELOPE].
messages = getMessages(folder) messages = getMessages(folder, [FETCH_ENVELOPE, FETCH_FLAGS, FETCH_CONTENT_INFO])
listMailFolders() traverses the folder hierarchy from the specified mail folder as the root and calls the callback function. When enterFunc() and exitFunc() are specified, they are called when the traversal enters/exits a subfolder.
listMailFolders(folder, println)