Sample code for 30+ languages & platforms
Lua

Set an IMAP Mailbox Quota (SETQUOTA)

See more IMAP Examples

Demonstrates the Chilkat Imap.SetQuota method, which sends the IMAP SETQUOTA command. The first argument is the quota root, the second is the resource (STORAGE or MESSAGE), and the third is the limit. The server must support the IMAP QUOTA extension.

Background: Setting a quota is an administrative operation, so the logged-in account must have permission to change it. For the STORAGE resource the limit is measured in units of 1024 octets, so a value of 500000 is roughly 500,000,000 bytes; MESSAGE instead caps the number of messages. Use GetQuotaRoot to read the current usage and limits back.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- Demonstrates the Imap.SetQuota method, which sends the IMAP SETQUOTA command.  The 1st
-- argument is the quota root, the 2nd is the resource ("STORAGE" or "MESSAGE"), and the 3rd is
-- the limit.  The server must support the IMAP QUOTA extension.

local imap = chilkat.Imap.new()

imap.ssl = true
imap.port = 993

local success = imap:connect("imap.example.com")
if not success then
    print(imap.last_error_text)
    return
end

success = imap:login("user@example.com", "myPassword")
if not success then
    print(imap.last_error_text)
    return
end

-- Set the STORAGE limit for the "Mailbox" quota root.  STORAGE is measured in units of 1024
-- octets, so 500000 is approximately 500,000,000 bytes.
local quotaKb = 500000
success = imap:set_quota("Mailbox", "STORAGE", quotaKb)
if not success then
    print(imap.last_error_text)
    return
end

print("Quota set.")

success = imap:disconnect()
if not success then
    print(imap.last_error_text)
    return
end