Documentation
¶
Index ¶
- Variables
- func FormatMillisTimestamp(ms int64) string
- func FromUnixMillis(ms int64) time.Time
- func NewRateLimiter() *rate.Limiter
- func ToUnixMillis(t time.Time) int64
- type APIError
- type AccountData
- type AccountDetails
- type AccountDetailsResponse
- type AccountsResponse
- type AddDomainRequest
- type AddGroupMembersRequest
- type AdminClient
- func (ac *AdminClient) AddDomain(ctx context.Context, domainName string) (*Domain, error)
- func (ac *AdminClient) AddGroupMembers(ctx context.Context, zgid int64, members []GroupMemberToAdd) error
- func (ac *AdminClient) CreateGroup(ctx context.Context, req CreateGroupRequest) (*Group, error)
- func (ac *AdminClient) CreateUser(ctx context.Context, req CreateUserRequest) (*User, error)
- func (ac *AdminClient) DeleteGroup(ctx context.Context, zgid int64) error
- func (ac *AdminClient) DeleteUser(ctx context.Context, zuid int64) error
- func (ac *AdminClient) DisableUser(ctx context.Context, zuid int64, opts DisableUserOpts) error
- func (ac *AdminClient) EnableUser(ctx context.Context, zuid int64) error
- func (ac *AdminClient) GetAuditLogs(ctx context.Context, startTime, endTime time.Time, searchKey string, limit int) ([]AuditLog, error)
- func (ac *AdminClient) GetDomain(ctx context.Context, domainName string) (*Domain, error)
- func (ac *AdminClient) GetGroup(ctx context.Context, zgid int64) (*Group, error)
- func (ac *AdminClient) GetGroupByEmail(ctx context.Context, email string) (*Group, error)
- func (ac *AdminClient) GetGroupMembers(ctx context.Context, zgid int64) ([]GroupMember, error)
- func (ac *AdminClient) GetLoginHistory(ctx context.Context, mode string, startTime, endTime time.Time, batchSize int) ([]LoginHistoryEntry, error)
- func (ac *AdminClient) GetSMTPLogs(ctx context.Context, startTime, endTime time.Time, ...) ([]SMTPLogEntry, error)
- func (ac *AdminClient) GetUser(ctx context.Context, accountID int64) (*User, error)
- func (ac *AdminClient) GetUserByEmail(ctx context.Context, email string) (*User, error)
- func (ac *AdminClient) GetUserByIdentifier(ctx context.Context, identifier string) (*User, error)
- func (ac *AdminClient) ListDomains(ctx context.Context) ([]Domain, error)
- func (ac *AdminClient) ListGroups(ctx context.Context, start, limit int) ([]Group, error)
- func (ac *AdminClient) ListUsers(ctx context.Context, start, limit int) ([]User, error)
- func (ac *AdminClient) RemoveGroupMembers(ctx context.Context, zgid int64, members []GroupMemberToRemove) error
- func (ac *AdminClient) UpdateDomainSettings(ctx context.Context, domainName, mode string) error
- func (ac *AdminClient) UpdateGroup(ctx context.Context, zgid int64, name, description string) error
- func (ac *AdminClient) UpdateUserRole(ctx context.Context, zuid int64, newRole string) error
- func (ac *AdminClient) VerifyDomain(ctx context.Context, domainName, method string) error
- type AdminService
- type Attachment
- type AttachmentListResponse
- type AttachmentReference
- type AttachmentUploadResponse
- type AuditLog
- type AuditLogResponse
- type Client
- func (c *Client) Do(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
- func (c *Client) DoAuth(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
- func (c *Client) DoMail(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
- type CreateGroupRequest
- type CreateUserRequest
- type DKIM
- type DeleteConfirmation
- type DeliveryLog
- type DeliveryLogListResponse
- type DisableUserOpts
- type Domain
- type DomainDetailResponse
- type DomainListResponse
- type DomainModeRequest
- type EmailAddress
- type Folder
- type FolderListResponse
- type ForwardSettings
- type Group
- type GroupDetailResponse
- type GroupListResponse
- type GroupMember
- type GroupMemberToAdd
- type GroupMemberToRemove
- type GroupMembersResponse
- type Label
- type LabelListResponse
- type LoginHistoryEntry
- type LoginHistoryResponse
- type MailAccount
- type MailAccountListResponse
- type MailAdminClient
- func (mac *MailAdminClient) GetDeliveryLogs(ctx context.Context, start, limit int) ([]DeliveryLog, error)
- func (mac *MailAdminClient) GetRetentionPolicy(ctx context.Context) (json.RawMessage, error)
- func (mac *MailAdminClient) GetSpamSettings(ctx context.Context, category SpamCategory) ([]string, error)
- func (mac *MailAdminClient) UpdateSpamList(ctx context.Context, category SpamCategory, values []string) error
- type MailClient
- func (mc *MailClient) AddSignature(ctx context.Context, sig *Signature) (string, error)
- func (mc *MailClient) AddVacationReply(ctx context.Context, vacation *VacationReply) error
- func (mc *MailClient) DisableVacationReply(ctx context.Context) error
- func (mc *MailClient) DownloadAttachment(ctx context.Context, folderID, messageID, attachmentID, destPath string) error
- func (mc *MailClient) ForwardEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
- func (mc *MailClient) GetAccountDetails(ctx context.Context) (*AccountDetails, error)
- func (mc *MailClient) GetFolderByName(ctx context.Context, name string) (*Folder, error)
- func (mc *MailClient) GetMessageContent(ctx context.Context, folderID, messageID string) (*MessageContent, error)
- func (mc *MailClient) GetMessageMetadata(ctx context.Context, folderID, messageID string) (*MessageMetadata, error)
- func (mc *MailClient) GetThread(ctx context.Context, folderID, threadID string, limit int) ([]MessageSummary, error)
- func (mc *MailClient) ListAttachments(ctx context.Context, folderID, messageID string) ([]Attachment, error)
- func (mc *MailClient) ListFolders(ctx context.Context) ([]Folder, error)
- func (mc *MailClient) ListLabels(ctx context.Context) ([]Label, error)
- func (mc *MailClient) ListMessages(ctx context.Context, folderID string, start, limit int) ([]MessageSummary, error)
- func (mc *MailClient) ListSignatures(ctx context.Context) ([]Signature, error)
- func (mc *MailClient) ReplyAllToEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
- func (mc *MailClient) ReplyToEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
- func (mc *MailClient) SearchMessages(ctx context.Context, searchKey string, start, limit int) ([]MessageSummary, error)
- func (mc *MailClient) SendEmail(ctx context.Context, req *SendEmailRequest) error
- func (mc *MailClient) UpdateDisplayName(ctx context.Context, displayName string) error
- func (mc *MailClient) UploadAttachment(ctx context.Context, filePath string) (*AttachmentReference, error)
- type MailService
- type MessageContent
- type MessageContentResponse
- type MessageListResponse
- type MessageMetadata
- type MessageMetadataResponse
- type MessageSummary
- type PageIterator
- type RateLimitTransport
- type RemoveGroupMembersRequest
- type SMTPLogEntry
- type SMTPLogResponse
- type SearchQuery
- func (sq *SearchQuery) Build() string
- func (sq *SearchQuery) DateAfter(date time.Time) *SearchQuery
- func (sq *SearchQuery) DateBefore(date time.Time) *SearchQuery
- func (sq *SearchQuery) From(email string) *SearchQuery
- func (sq *SearchQuery) HasAttachment() *SearchQuery
- func (sq *SearchQuery) IsEmpty() bool
- func (sq *SearchQuery) IsUnread() *SearchQuery
- func (sq *SearchQuery) Subject(text string) *SearchQuery
- func (sq *SearchQuery) Text(query string) *SearchQuery
- func (sq *SearchQuery) To(email string) *SearchQuery
- type SendEmailRequest
- type SendEmailResponse
- type Signature
- type SignatureCreateResponse
- type SignatureListResponse
- type SpamCategory
- type SpamListEntry
- type SpamSettingsResponse
- type SpamUpdateRequest
- type UpdateUserRequest
- type User
- type UserDetailResponse
- type UserListResponse
- type VacationReply
Constants ¶
This section is empty.
Variables ¶
var SpamCategoryMap = map[string]SpamCategory{ "allowlist-email": WhiteListEmail, "blocklist-email": SpamEmail, "reject-email": RejectEmail, "quarantine-email": QuarantineEmail, "trusted-email": TrustedEmail, "allowlist-domain": WhiteListDomain, "blocklist-domain": SpamDomain, "reject-domain": RejectDomain, "quarantine-domain": QuarantineDomain, "trusted-domain": TrustedDomain, "blocklist-tld": SpamTLD, "reject-tld": RejectTLD, "quarantine-tld": QuarantineTLD, "allowlist-ip": WhiteListIP, "blocklist-ip": SpamIP, "reject-ip": RejectIP, "quarantine-ip": QuarantineIP, }
SpamCategoryMap provides CLI-friendly name mapping to Zoho API enum values
Functions ¶
func FormatMillisTimestamp ¶
FormatMillisTimestamp formats a millisecond timestamp for display in RFC3339
func FromUnixMillis ¶
FromUnixMillis converts Unix milliseconds (int64) to time.Time
func NewRateLimiter ¶
NewRateLimiter creates a rate limiter configured for Zoho's API limits. Zoho allows 30 requests per minute. We use 25 req/min for safety margin. Burst of 5 allows small batch operations without blocking.
func ToUnixMillis ¶
ToUnixMillis converts time.Time to Unix milliseconds (int64)
Types ¶
type APIError ¶
type APIError struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data struct {
MoreInfo string `json:"moreInfo"`
} `json:"data"`
}
APIError represents an error response from the Zoho API
type AccountData ¶
type AccountData struct {
AccountID string `json:"accountId"`
ZUID int64 `json:"zuid"`
PolicyID struct {
Zoid int64 `json:"zoid"`
} `json:"policyId"`
PrimaryEmailAddress string `json:"primaryEmailAddress"`
DisplayName string `json:"displayName"`
Role string `json:"role"`
}
AccountData represents a single account from /api/accounts
type AccountDetails ¶
type AccountDetails struct {
AccountDisplayName string `json:"accountDisplayName"`
DisplayName string `json:"displayName"`
PrimaryEmailAddress string `json:"primaryEmailAddress"`
EmailAddress []EmailAddress `json:"emailAddress"`
VacationResponse json.RawMessage `json:"vacationResponse,omitempty"`
ForwardDetails json.RawMessage `json:"forwardDetails,omitempty"`
}
AccountDetails represents account details including vacation and forwarding settings
type AccountDetailsResponse ¶
type AccountDetailsResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data AccountDetails `json:"data"`
}
AccountDetailsResponse is the response for get account details
type AccountsResponse ¶
type AccountsResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []AccountData `json:"data"`
}
AccountsResponse is the response from GET /api/accounts
type AddDomainRequest ¶
type AddDomainRequest struct {
DomainName string `json:"domainName"`
}
AddDomainRequest is the request body for POST /api/organization/{zoid}/domains
type AddGroupMembersRequest ¶
type AddGroupMembersRequest struct {
Mode string `json:"mode"` // "addMailGroupMember"
MailGroupMemberList []GroupMemberToAdd `json:"mailGroupMemberList"`
}
AddGroupMembersRequest is the request body for adding group members
type AdminClient ¶
type AdminClient struct {
// contains filtered or unexported fields
}
AdminClient wraps the Zoho Client with admin-specific functionality
func NewAdminClient ¶
func NewAdminClient(cfg *config.Config, tokenSource oauth2.TokenSource) (*AdminClient, error)
NewAdminClient creates a new AdminClient with the given config and token source It automatically resolves and caches the organization ID
func (*AdminClient) AddGroupMembers ¶
func (ac *AdminClient) AddGroupMembers(ctx context.Context, zgid int64, members []GroupMemberToAdd) error
AddGroupMembers adds members to a group with batching for large member lists
func (*AdminClient) CreateGroup ¶
func (ac *AdminClient) CreateGroup(ctx context.Context, req CreateGroupRequest) (*Group, error)
CreateGroup creates a new group
func (*AdminClient) CreateUser ¶
func (ac *AdminClient) CreateUser(ctx context.Context, req CreateUserRequest) (*User, error)
CreateUser creates a new user in the organization
func (*AdminClient) DeleteGroup ¶
func (ac *AdminClient) DeleteGroup(ctx context.Context, zgid int64) error
DeleteGroup permanently deletes a group
func (*AdminClient) DeleteUser ¶
func (ac *AdminClient) DeleteUser(ctx context.Context, zuid int64) error
DeleteUser permanently deletes a user from the organization
func (*AdminClient) DisableUser ¶
func (ac *AdminClient) DisableUser(ctx context.Context, zuid int64, opts DisableUserOpts) error
DisableUser deactivates a user account with specified options
func (*AdminClient) EnableUser ¶
func (ac *AdminClient) EnableUser(ctx context.Context, zuid int64) error
EnableUser activates a user account
func (*AdminClient) GetAuditLogs ¶
func (ac *AdminClient) GetAuditLogs(ctx context.Context, startTime, endTime time.Time, searchKey string, limit int) ([]AuditLog, error)
GetAuditLogs fetches admin action audit logs with cursor pagination
func (*AdminClient) GetGroupByEmail ¶
GetGroupByEmail fetches a group by email address This iterates through all groups until a match is found
func (*AdminClient) GetGroupMembers ¶
func (ac *AdminClient) GetGroupMembers(ctx context.Context, zgid int64) ([]GroupMember, error)
GetGroupMembers fetches the member list for a group
func (*AdminClient) GetLoginHistory ¶
func (ac *AdminClient) GetLoginHistory(ctx context.Context, mode string, startTime, endTime time.Time, batchSize int) ([]LoginHistoryEntry, error)
GetLoginHistory fetches login history logs with scroll-based pagination
func (*AdminClient) GetSMTPLogs ¶
func (ac *AdminClient) GetSMTPLogs(ctx context.Context, startTime, endTime time.Time, searchCriteria, searchKey string, limit int) ([]SMTPLogEntry, error)
GetSMTPLogs fetches SMTP transaction logs with forward pagination
func (*AdminClient) GetUserByEmail ¶
GetUserByEmail fetches a user by email address This iterates through all users until a match is found
func (*AdminClient) GetUserByIdentifier ¶
GetUserByIdentifier is a helper that accepts either a ZUID or email address
func (*AdminClient) ListDomains ¶
func (ac *AdminClient) ListDomains(ctx context.Context) ([]Domain, error)
ListDomains fetches all domains in the organization
func (*AdminClient) ListGroups ¶
ListGroups fetches a list of groups with pagination
func (*AdminClient) RemoveGroupMembers ¶
func (ac *AdminClient) RemoveGroupMembers(ctx context.Context, zgid int64, members []GroupMemberToRemove) error
RemoveGroupMembers removes members from a group
func (*AdminClient) UpdateDomainSettings ¶
func (ac *AdminClient) UpdateDomainSettings(ctx context.Context, domainName, mode string) error
UpdateDomainSettings updates domain settings using the specified mode
func (*AdminClient) UpdateGroup ¶
UpdateGroup updates a group's name and/or description
func (*AdminClient) UpdateUserRole ¶
UpdateUserRole changes a user's role in the organization
func (*AdminClient) VerifyDomain ¶
func (ac *AdminClient) VerifyDomain(ctx context.Context, domainName, method string) error
VerifyDomain verifies domain ownership using the specified method
type AdminService ¶
type AdminService interface {
ListUsers(ctx context.Context, start, limit int) ([]User, error)
GetUser(ctx context.Context, accountID int64) (*User, error)
GetUserByEmail(ctx context.Context, email string) (*User, error)
GetUserByIdentifier(ctx context.Context, identifier string) (*User, error)
CreateUser(ctx context.Context, req CreateUserRequest) (*User, error)
UpdateUserRole(ctx context.Context, zuid int64, newRole string) error
EnableUser(ctx context.Context, zuid int64) error
DisableUser(ctx context.Context, zuid int64, opts DisableUserOpts) error
DeleteUser(ctx context.Context, zuid int64) error
ListGroups(ctx context.Context, start, limit int) ([]Group, error)
GetGroup(ctx context.Context, zgid int64) (*Group, error)
GetGroupByEmail(ctx context.Context, email string) (*Group, error)
GetGroupMembers(ctx context.Context, zgid int64) ([]GroupMember, error)
CreateGroup(ctx context.Context, req CreateGroupRequest) (*Group, error)
UpdateGroup(ctx context.Context, zgid int64, name, description string) error
DeleteGroup(ctx context.Context, zgid int64) error
AddGroupMembers(ctx context.Context, zgid int64, members []GroupMemberToAdd) error
RemoveGroupMembers(ctx context.Context, zgid int64, members []GroupMemberToRemove) error
ListDomains(ctx context.Context) ([]Domain, error)
GetDomain(ctx context.Context, domainName string) (*Domain, error)
AddDomain(ctx context.Context, domainName string) (*Domain, error)
VerifyDomain(ctx context.Context, domainName, method string) error
UpdateDomainSettings(ctx context.Context, domainName, mode string) error
GetAuditLogs(ctx context.Context, startTime, endTime time.Time, searchKey string, limit int) ([]AuditLog, error)
GetLoginHistory(ctx context.Context, mode string, startTime, endTime time.Time, batchSize int) ([]LoginHistoryEntry, error)
GetSMTPLogs(ctx context.Context, startTime, endTime time.Time, searchCriteria, searchKey string, limit int) ([]SMTPLogEntry, error)
}
AdminService defines the interface for Zoho admin operations.
type Attachment ¶
type Attachment struct {
AttachmentID string `json:"attachmentId"`
AttachmentName string `json:"attachmentName"`
AttachmentSize int64 `json:"attachmentSize"`
AttachmentType string `json:"attachmentType"` // MIME type
}
Attachment represents a message attachment
type AttachmentListResponse ¶
type AttachmentListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []Attachment `json:"data"`
}
AttachmentListResponse is the response for list attachments
type AttachmentReference ¶
type AttachmentReference struct {
StoreName string `json:"storeName"`
AttachmentName string `json:"attachmentName"`
AttachmentPath string `json:"attachmentPath"`
}
AttachmentReference represents an uploaded attachment reference
type AttachmentUploadResponse ¶
type AttachmentUploadResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data AttachmentReference `json:"data"`
}
AttachmentUploadResponse is the response for attachment upload
type AuditLog ¶
type AuditLog struct {
SubCategory string `json:"subCategory"`
Data json.RawMessage `json:"data"`
Type string `json:"type"`
RequestTime int64 `json:"requestTime"` // Unix milliseconds
PerformedBy string `json:"performedBy"`
AuditLogType string `json:"auditLogType"`
ClientIP string `json:"clientIp"`
MainCategory string `json:"mainCategory"`
OperationType string `json:"operationType"`
PerformedOn string `json:"performedOn"`
Category string `json:"category"`
Operation string `json:"operation"`
}
AuditLog represents an admin action audit log entry
type AuditLogResponse ¶
type AuditLogResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data struct {
Audit []AuditLog `json:"audit"`
LastIndexTime string `json:"lastIndexTime"`
LastEntityID string `json:"lastEntityId"`
} `json:"data"`
}
AuditLogResponse is the response from GET /api/organization/{zoid}/activity
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a region-aware HTTP client for Zoho APIs.
func NewClient ¶
NewClient creates a new Zoho API client with OAuth2 authentication and rate limiting.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
Do executes an HTTP request to the Zoho API. The path should be relative (e.g., "/admin/v1/users"). The caller is responsible for reading the response body and checking the status code.
func (*Client) DoAuth ¶
func (c *Client) DoAuth(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
DoAuth executes an HTTP request to the Zoho Accounts API. The path should be relative (e.g., "/oauth/v2/token/info"). Does NOT add OAuth2 bearer token (auth endpoints use different auth methods).
type CreateGroupRequest ¶
type CreateGroupRequest struct {
GroupName string `json:"groupName"`
GroupEmailAddress string `json:"groupEmailAddress"`
Description string `json:"description"`
AdminsEmailList []string `json:"adminsEmailList,omitempty"`
MembersEmailList []string `json:"membersEmailList,omitempty"`
}
CreateGroupRequest is the request body for POST /api/organization/{zoid}/groups
type CreateUserRequest ¶
type CreateUserRequest struct {
PrimaryEmailAddress string `json:"primaryEmailAddress"`
Password string `json:"password"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
DisplayName string `json:"displayName"`
Role string `json:"role"`
Country string `json:"country"`
Language string `json:"language"`
TimeZone string `json:"timeZone"`
OneTimePassword bool `json:"oneTimePassword"`
GroupMailList []string `json:"groupMailList,omitempty"`
}
CreateUserRequest is the request body for POST /api/organization/{zoid}/accounts
type DKIM ¶
type DKIM struct {
Selector string `json:"selector"`
DomainName string `json:"domainName"`
TXTRecord string `json:"txtRecord"`
Status bool `json:"status"`
}
DKIM represents DKIM settings for a domain
type DeleteConfirmation ¶
type DeleteConfirmation struct {
Mode string `json:"mode"` // "deleteUser" or similar
}
DeleteConfirmation is the request body for delete operations
type DeliveryLog ¶
type DeliveryLog struct {
MessageID string `json:"messageId"`
Subject string `json:"subject"`
FromAddress string `json:"fromAddress"`
ToAddress string `json:"toAddress"`
Status string `json:"status"`
SentTime string `json:"sentTime"`
DeliveryTime string `json:"deliveryTime"`
}
DeliveryLog represents a mail delivery log entry
type DeliveryLogListResponse ¶
type DeliveryLogListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []DeliveryLog `json:"data"`
}
DeliveryLogListResponse is the response for delivery logs
type DisableUserOpts ¶
type DisableUserOpts struct {
BlockIncoming bool `json:"blockIncoming,omitempty"`
RemoveMailForward bool `json:"removeMailForward,omitempty"`
RemoveGroupMembership bool `json:"removeGroupMembership,omitempty"`
RemoveAlias bool `json:"removeAlias,omitempty"`
}
DisableUserOpts contains options for disabling a user
type Domain ¶
type Domain struct {
DomainName string `json:"domainName"`
DomainID string `json:"domainId"`
VerificationStatus bool `json:"verificationStatus"`
DKIMStatus bool `json:"dkimstatus"`
SPFStatus bool `json:"spfstatus"`
MXStatus string `json:"mxstatus"`
VerifiedDate int64 `json:"verifiedDate"` // Unix milliseconds
MailHostingEnabled bool `json:"mailHostingEnabled"`
IsDomainAlias bool `json:"isDomainAlias"`
IsExpired bool `json:"isExpired"`
Primary bool `json:"primary"`
CNAMEVerificationCode string `json:"CNAMEVerificationCode"`
HTMLVerificationCode string `json:"HTMLVerificationCode"`
TXTVerificationCode string `json:"txtRecord"` // TXT record value for DNS verification
}
Domain represents a domain in the organization
type DomainDetailResponse ¶
type DomainDetailResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data Domain `json:"data"`
}
DomainDetailResponse is the response from GET /api/organization/{zoid}/domains/{domainName}
type DomainListResponse ¶
type DomainListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data struct {
DomainVO []Domain `json:"domainVO"`
} `json:"data"`
}
DomainListResponse is the response from GET /api/organization/{zoid}/domains
type DomainModeRequest ¶
type DomainModeRequest struct {
Mode string `json:"mode"`
}
DomainModeRequest is the request body for domain mode operations
type EmailAddress ¶
type EmailAddress struct {
MailID string `json:"mailId"`
IsAlias bool `json:"isAlias"`
IsPrimary bool `json:"isPrimary"`
}
EmailAddress represents a Zoho user email address entry
type Folder ¶
type Folder struct {
FolderID string `json:"folderId"`
FolderName string `json:"folderName"`
FolderType string `json:"folderType"`
Path string `json:"path"`
UnreadCount int `json:"unreadCount"`
MessageCount int `json:"messageCount"`
}
Folder represents a mail folder
type FolderListResponse ¶
type FolderListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []Folder `json:"data"`
}
FolderListResponse is the response for list folders
type ForwardSettings ¶
type ForwardSettings struct {
Enabled bool `json:"enabled"`
ForwardTo string `json:"forwardTo"`
KeepCopy bool `json:"keepCopy"`
}
ForwardSettings represents email forwarding settings
type Group ¶
type Group struct {
ZGID int64 `json:"zgid"`
GroupName string `json:"groupName"`
GroupEmailAddress string `json:"groupEmailAddress"`
Description string `json:"description"`
MembersCount int `json:"membersCount"`
}
Group represents a Zoho group
type GroupDetailResponse ¶
type GroupDetailResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data Group `json:"data"`
}
GroupDetailResponse is the response from GET /api/organization/{zoid}/groups/{zgid}
type GroupListResponse ¶
type GroupListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data struct {
Groups []Group `json:"groups"`
Count int `json:"count"`
} `json:"data"`
}
GroupListResponse is the response from GET /api/organization/{zoid}/groups
type GroupMember ¶
type GroupMember struct {
MemberEmailID string `json:"memberEmailID"`
Role string `json:"role"`
ZUID int64 `json:"zuid"`
}
GroupMember represents a member of a group
type GroupMemberToAdd ¶
type GroupMemberToAdd struct {
MemberEmailID string `json:"memberEmailID"`
Role string `json:"role"`
}
GroupMemberToAdd represents a member to add to a group
type GroupMemberToRemove ¶
type GroupMemberToRemove struct {
MemberEmailID string `json:"memberEmailID"`
}
GroupMemberToRemove represents a member to remove from a group
type GroupMembersResponse ¶
type GroupMembersResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []GroupMember `json:"data"`
}
GroupMembersResponse is the response from GET /api/organization/{zoid}/groups/{zgid}/members
type Label ¶
type Label struct {
LabelID string `json:"labelId"`
LabelName string `json:"labelName"`
LabelColor string `json:"labelColor"`
}
Label represents a mail label/tag
type LabelListResponse ¶
type LabelListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []Label `json:"data"`
}
LabelListResponse is the response for list labels
type LoginHistoryEntry ¶
type LoginHistoryEntry struct {
UserID int64 `json:"userId"`
EmailAddress string `json:"emailAddress"`
IPAddress string `json:"ipAddress"`
LoginTime int64 `json:"loginTime"` // Unix milliseconds
Status string `json:"status"`
AccessType string `json:"accessType"`
ClientInfo string `json:"clientInfo"`
}
LoginHistoryEntry represents a login history log entry
type LoginHistoryResponse ¶
type LoginHistoryResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data struct {
LoginHistory []LoginHistoryEntry `json:"loginHistory"`
ScrollID string `json:"scrollId"`
} `json:"data"`
}
LoginHistoryResponse is the response from GET /api/organization/{zoid}/accounts/reports/loginHistory
type MailAccount ¶
type MailAccount struct {
AccountID string `json:"accountId"`
EmailAddress []EmailAddress `json:"emailAddress"`
PrimaryEmailAddress string `json:"primaryEmailAddress"`
AccountDisplayName string `json:"accountDisplayName"`
DisplayName string `json:"displayName"`
Type string `json:"type"`
Role string `json:"role"`
}
MailAccount represents a Zoho Mail account
type MailAccountListResponse ¶
type MailAccountListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []MailAccount `json:"data"`
}
MailAccountListResponse is the response for list accounts
type MailAdminClient ¶
type MailAdminClient struct {
// contains filtered or unexported fields
}
MailAdminClient wraps the Zoho Client with mail admin-specific functionality
func NewMailAdminClient ¶
func NewMailAdminClient(cfg *config.Config, tokenSource oauth2.TokenSource) (*MailAdminClient, error)
NewMailAdminClient creates a new MailAdminClient with the given config and token source It automatically resolves and caches the organization ID
func (*MailAdminClient) GetDeliveryLogs ¶
func (mac *MailAdminClient) GetDeliveryLogs(ctx context.Context, start, limit int) ([]DeliveryLog, error)
GetDeliveryLogs fetches delivery logs with pagination
func (*MailAdminClient) GetRetentionPolicy ¶
func (mac *MailAdminClient) GetRetentionPolicy(ctx context.Context) (json.RawMessage, error)
GetRetentionPolicy fetches retention policy settings Returns raw JSON since policy structure is not well-documented
func (*MailAdminClient) GetSpamSettings ¶
func (mac *MailAdminClient) GetSpamSettings(ctx context.Context, category SpamCategory) ([]string, error)
GetSpamSettings fetches spam settings for a given category NOTE: Research confidence is MEDIUM for this endpoint - may not be supported
func (*MailAdminClient) UpdateSpamList ¶
func (mac *MailAdminClient) UpdateSpamList(ctx context.Context, category SpamCategory, values []string) error
UpdateSpamList updates spam settings for a given category
type MailClient ¶
type MailClient struct {
// contains filtered or unexported fields
}
MailClient wraps the Zoho Client with mail-specific functionality
func NewMailClient ¶
func NewMailClient(cfg *config.Config, tokenSource oauth2.TokenSource) (*MailClient, error)
NewMailClient creates a new MailClient with the given config and token source It automatically resolves and caches the primary account ID
func (*MailClient) AddSignature ¶
AddSignature creates a new email signature and returns the signature ID
func (*MailClient) AddVacationReply ¶
func (mc *MailClient) AddVacationReply(ctx context.Context, vacation *VacationReply) error
AddVacationReply enables vacation auto-reply with specified settings
func (*MailClient) DisableVacationReply ¶
func (mc *MailClient) DisableVacationReply(ctx context.Context) error
DisableVacationReply disables vacation auto-reply
func (*MailClient) DownloadAttachment ¶
func (mc *MailClient) DownloadAttachment(ctx context.Context, folderID, messageID, attachmentID, destPath string) error
DownloadAttachment downloads an attachment to a file
func (*MailClient) ForwardEmail ¶
func (mc *MailClient) ForwardEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
ForwardEmail forwards a message to new recipients
func (*MailClient) GetAccountDetails ¶
func (mc *MailClient) GetAccountDetails(ctx context.Context) (*AccountDetails, error)
GetAccountDetails fetches account details including vacation reply and forwarding settings
func (*MailClient) GetFolderByName ¶
GetFolderByName finds a folder by name (case-insensitive)
func (*MailClient) GetMessageContent ¶
func (mc *MailClient) GetMessageContent(ctx context.Context, folderID, messageID string) (*MessageContent, error)
GetMessageContent fetches the HTML body content for a specific message
func (*MailClient) GetMessageMetadata ¶
func (mc *MailClient) GetMessageMetadata(ctx context.Context, folderID, messageID string) (*MessageMetadata, error)
GetMessageMetadata fetches full metadata for a specific message
func (*MailClient) GetThread ¶
func (mc *MailClient) GetThread(ctx context.Context, folderID, threadID string, limit int) ([]MessageSummary, error)
GetThread fetches all messages in a thread by filtering folder messages
func (*MailClient) ListAttachments ¶
func (mc *MailClient) ListAttachments(ctx context.Context, folderID, messageID string) ([]Attachment, error)
ListAttachments fetches all attachments for a message
func (*MailClient) ListFolders ¶
func (mc *MailClient) ListFolders(ctx context.Context) ([]Folder, error)
ListFolders fetches all folders for the primary account
func (*MailClient) ListLabels ¶
func (mc *MailClient) ListLabels(ctx context.Context) ([]Label, error)
ListLabels fetches all labels for the primary account
func (*MailClient) ListMessages ¶
func (mc *MailClient) ListMessages(ctx context.Context, folderID string, start, limit int) ([]MessageSummary, error)
ListMessages fetches messages from a folder with pagination
func (*MailClient) ListSignatures ¶
func (mc *MailClient) ListSignatures(ctx context.Context) ([]Signature, error)
ListSignatures fetches all email signatures for the primary account
func (*MailClient) ReplyAllToEmail ¶
func (mc *MailClient) ReplyAllToEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
ReplyAllToEmail replies to all recipients of a message
func (*MailClient) ReplyToEmail ¶
func (mc *MailClient) ReplyToEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
ReplyToEmail replies to a message
func (*MailClient) SearchMessages ¶
func (mc *MailClient) SearchMessages(ctx context.Context, searchKey string, start, limit int) ([]MessageSummary, error)
SearchMessages searches messages using Zoho search syntax
func (*MailClient) SendEmail ¶
func (mc *MailClient) SendEmail(ctx context.Context, req *SendEmailRequest) error
SendEmail sends a new email message
func (*MailClient) UpdateDisplayName ¶
func (mc *MailClient) UpdateDisplayName(ctx context.Context, displayName string) error
UpdateDisplayName updates the account display name
func (*MailClient) UploadAttachment ¶
func (mc *MailClient) UploadAttachment(ctx context.Context, filePath string) (*AttachmentReference, error)
UploadAttachment uploads a file and returns an attachment reference for use in send requests
type MailService ¶
type MailService interface {
// Folder and label operations
ListFolders(ctx context.Context) ([]Folder, error)
GetFolderByName(ctx context.Context, name string) (*Folder, error)
ListLabels(ctx context.Context) ([]Label, error)
// Message operations
ListMessages(ctx context.Context, folderID string, start, limit int) ([]MessageSummary, error)
GetMessageMetadata(ctx context.Context, folderID, messageID string) (*MessageMetadata, error)
GetMessageContent(ctx context.Context, folderID, messageID string) (*MessageContent, error)
SearchMessages(ctx context.Context, searchKey string, start, limit int) ([]MessageSummary, error)
GetThread(ctx context.Context, folderID, threadID string, limit int) ([]MessageSummary, error)
// Attachment operations
ListAttachments(ctx context.Context, folderID, messageID string) ([]Attachment, error)
DownloadAttachment(ctx context.Context, folderID, messageID, attachmentID, destPath string) error
UploadAttachment(ctx context.Context, filePath string) (*AttachmentReference, error)
// Send operations
SendEmail(ctx context.Context, req *SendEmailRequest) error
ReplyToEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
ReplyAllToEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
ForwardEmail(ctx context.Context, messageID string, req *SendEmailRequest) error
// Settings operations
ListSignatures(ctx context.Context) ([]Signature, error)
AddSignature(ctx context.Context, sig *Signature) (string, error)
GetAccountDetails(ctx context.Context) (*AccountDetails, error)
AddVacationReply(ctx context.Context, vacation *VacationReply) error
DisableVacationReply(ctx context.Context) error
UpdateDisplayName(ctx context.Context, displayName string) error
}
MailService defines the interface for Zoho mail operations.
type MessageContent ¶
type MessageContent struct {
MessageID json.Number `json:"messageId"`
Content string `json:"content"` // HTML body
}
MessageContent represents message body content
type MessageContentResponse ¶
type MessageContentResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data MessageContent `json:"data"`
}
MessageContentResponse is the response for message content
type MessageListResponse ¶
type MessageListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []MessageSummary `json:"data"`
}
MessageListResponse is the response for list messages
type MessageMetadata ¶
type MessageMetadata struct {
MessageID string `json:"messageId"`
ThreadID string `json:"threadId"`
FolderID string `json:"folderId"`
Subject string `json:"subject"`
FromAddress string `json:"fromAddress"`
Sender string `json:"sender"`
ToAddress string `json:"toAddress"`
CcAddress string `json:"ccAddress"`
SentDateInGMT string `json:"sentDateInGMT"` // Unix milliseconds (as string)
ReceivedTime string `json:"receivedTime"`
MessageSize string `json:"messageSize"`
HasAttachment string `json:"hasAttachment"` // "0", "1", or "true"/"false"
HasInline string `json:"hasInline"`
Status string `json:"status"`
Priority string `json:"priority"`
FlagID string `json:"flagid"`
}
MessageMetadata represents full message metadata Note: Zoho returns most numeric/boolean fields as quoted strings
type MessageMetadataResponse ¶
type MessageMetadataResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data MessageMetadata `json:"data"`
}
MessageMetadataResponse is the response for message details
type MessageSummary ¶
type MessageSummary struct {
MessageID string `json:"messageId"`
ThreadID string `json:"threadId"`
Subject string `json:"subject"`
FromAddress string `json:"fromAddress"`
Sender string `json:"sender"`
ReceivedTime string `json:"receivedTime"` // Unix milliseconds (as string)
Status string `json:"status"`
HasAttachment string `json:"hasAttachment"` // "0" or "1"
FlagID string `json:"flagid"`
Priority string `json:"priority"`
Summary string `json:"summary"`
}
MessageSummary represents a message in list view Note: Zoho returns most numeric fields as quoted strings in message list responses
type PageIterator ¶
type PageIterator[T any] struct { // contains filtered or unexported fields }
PageIterator provides generic offset-based pagination for Zoho APIs
func NewPageIterator ¶
func NewPageIterator[T any](fetchFunc func(start, limit int) ([]T, error), pageSize int) *PageIterator[T]
NewPageIterator creates a new PageIterator with the given fetch function and page size
func (*PageIterator[T]) FetchAll ¶
func (p *PageIterator[T]) FetchAll() ([]T, error)
FetchAll fetches all pages until no more results are available
func (*PageIterator[T]) FetchPage ¶
func (p *PageIterator[T]) FetchPage(start int) ([]T, error)
FetchPage fetches a single page starting at the given offset
type RateLimitTransport ¶
type RateLimitTransport struct {
Base http.RoundTripper
Limiter *rate.Limiter
}
RateLimitTransport wraps an http.RoundTripper with rate limiting and 429 retry logic.
type RemoveGroupMembersRequest ¶
type RemoveGroupMembersRequest struct {
Mode string `json:"mode"` // "removeMailGroupMember"
MailGroupMemberList []GroupMemberToRemove `json:"mailGroupMemberList"`
}
RemoveGroupMembersRequest is the request body for removing group members
type SMTPLogEntry ¶
type SMTPLogEntry struct {
MessageID string `json:"messageId"`
FromAddress string `json:"fromAddr"`
ToAddresses []string `json:"toAddr"`
Subject string `json:"subject"`
TransactionID string `json:"transactionId"`
Timestamp int64 `json:"timestamp"` // Unix milliseconds
Status string `json:"status"`
}
SMTPLogEntry represents an SMTP transaction log entry
type SMTPLogResponse ¶
type SMTPLogResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data struct {
HasNext bool `json:"hnxt"`
HasPrevious bool `json:"hasPrevious"`
PageKey string `json:"pagekey"`
PagePrevKey string `json:"pagePrevKey"`
Response []SMTPLogEntry `json:"response"`
} `json:"data"`
}
SMTPLogResponse is the response from POST /api/organization/{zoid}/smtplogs
type SearchQuery ¶
type SearchQuery struct {
// contains filtered or unexported fields
}
SearchQuery builds Zoho Mail search syntax
func NewSearchQuery ¶
func NewSearchQuery() *SearchQuery
NewSearchQuery creates an empty search query builder
func (*SearchQuery) Build ¶
func (sq *SearchQuery) Build() string
Build returns the complete search query string
func (*SearchQuery) DateAfter ¶
func (sq *SearchQuery) DateAfter(date time.Time) *SearchQuery
DateAfter adds a filter for messages after a date
func (*SearchQuery) DateBefore ¶
func (sq *SearchQuery) DateBefore(date time.Time) *SearchQuery
DateBefore adds a filter for messages before a date
func (*SearchQuery) From ¶
func (sq *SearchQuery) From(email string) *SearchQuery
From adds a sender email filter
func (*SearchQuery) HasAttachment ¶
func (sq *SearchQuery) HasAttachment() *SearchQuery
HasAttachment adds a filter for messages with attachments
func (*SearchQuery) IsEmpty ¶
func (sq *SearchQuery) IsEmpty() bool
IsEmpty returns true if no search criteria have been added
func (*SearchQuery) IsUnread ¶
func (sq *SearchQuery) IsUnread() *SearchQuery
IsUnread adds a filter for unread messages
func (*SearchQuery) Subject ¶
func (sq *SearchQuery) Subject(text string) *SearchQuery
Subject adds a subject text filter
func (*SearchQuery) Text ¶
func (sq *SearchQuery) Text(query string) *SearchQuery
Text adds a free-text search query
func (*SearchQuery) To ¶
func (sq *SearchQuery) To(email string) *SearchQuery
To adds a recipient email filter
type SendEmailRequest ¶
type SendEmailRequest struct {
FromAddress string `json:"fromAddress"`
ToAddress string `json:"toAddress"`
CcAddress string `json:"ccAddress,omitempty"`
BccAddress string `json:"bccAddress,omitempty"`
Subject string `json:"subject"`
Content string `json:"content"`
MailFormat string `json:"mailFormat,omitempty"` // "html" or "plaintext"
Action string `json:"action,omitempty"` // "reply", "replyall", "forward"
Attachments []AttachmentReference `json:"attachments,omitempty"`
}
SendEmailRequest represents a request to send an email
type SendEmailResponse ¶
type SendEmailResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
}
SendEmailResponse is the response for send email
type Signature ¶
type Signature struct {
ID string `json:"id"`
Name string `json:"name"`
Content string `json:"content"`
Position int `json:"position"` // 0=below quoted, 1=above quoted
AssignUsers string `json:"assignUsers,omitempty"` // comma-separated emails
}
Signature represents an email signature
type SignatureCreateResponse ¶
type SignatureCreateResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data struct {
ID string `json:"id"`
Name string `json:"name"`
} `json:"data"`
}
SignatureCreateResponse is the response for create signature
type SignatureListResponse ¶
type SignatureListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []Signature `json:"data"`
}
SignatureListResponse is the response for list signatures
type SpamCategory ¶
type SpamCategory string
SpamCategory represents spam filter category types
const ( // Email allowlist/blocklist WhiteListEmail SpamCategory = "WhiteListEmail" SpamEmail SpamCategory = "SpamEmail" RejectEmail SpamCategory = "RejectEmail" QuarantineEmail SpamCategory = "QuarantineEmail" TrustedEmail SpamCategory = "TrustedEmail" // Domain allowlist/blocklist WhiteListDomain SpamCategory = "WhiteListDomain" SpamDomain SpamCategory = "SpamDomain" RejectDomain SpamCategory = "RejectDomain" QuarantineDomain SpamCategory = "QuarantineDomain" TrustedDomain SpamCategory = "TrustedDomain" SpamTLD SpamCategory = "SpamTLD" RejectTLD SpamCategory = "RejectTLD" QuarantineTLD SpamCategory = "QuarantineTLD" // IP allowlist/blocklist WhiteListIP SpamCategory = "WhiteListIP" SpamIP SpamCategory = "SpamIP" RejectIP SpamCategory = "RejectIP" QuarantineIP SpamCategory = "QuarantineIP" )
Spam category constants for allowlist/blocklist operations
type SpamListEntry ¶
type SpamListEntry struct {
Category SpamCategory
Value string
}
SpamListEntry represents a spam list entry for display
type SpamSettingsResponse ¶
type SpamSettingsResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []string `json:"data"`
}
SpamSettingsResponse is the response for get spam settings
type SpamUpdateRequest ¶
type SpamUpdateRequest struct {
SpamCategory string `json:"spamCategory"`
Value []string `json:"Value"` // Capital V matches Zoho API
}
SpamUpdateRequest represents a request to update spam settings
type UpdateUserRequest ¶
type UpdateUserRequest struct {
Mode string `json:"mode"`
ZUID int64 `json:"zuid"`
NewRole string `json:"newRole,omitempty"`
}
UpdateUserRequest is the request body for PUT /api/organization/{zoid}/accounts/{accountId}
type User ¶
type User struct {
ZUID int64 `json:"zuid"`
AccountID string `json:"accountId"` // Zoho returns this as a quoted string
EmailAddress []EmailAddress `json:"emailAddress"`
PrimaryEmailID string `json:"primaryEmailAddress"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
DisplayName string `json:"displayName"`
Role string `json:"role"`
MailboxStatus string `json:"mailboxStatus"`
UsedStorage int64 `json:"usedStorage"`
PlanStorage int64 `json:"planStorage"`
TFAEnabled bool `json:"tfaEnabled"`
IMAPAccessEnabled bool `json:"imapAccessEnabled"`
POPAccessEnabled bool `json:"popAccessEnabled"`
LastLogin int64 `json:"lastLogin"` // Unix timestamp in milliseconds
}
User represents a Zoho user account Field types verified against official Zoho docs: https://www.zoho.com/mail/help/api/get-org-users-details.html
func (*User) PrimaryEmail ¶
PrimaryEmail returns the primary email address string for the user
type UserDetailResponse ¶
type UserDetailResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data User `json:"data"`
}
UserDetailResponse is the response from GET /api/organization/{zoid}/accounts/{accountId}
type UserListResponse ¶
type UserListResponse struct {
Status struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"status"`
Data []User `json:"data"`
}
UserListResponse is the response from GET /api/organization/{zoid}/accounts
type VacationReply ¶
type VacationReply struct {
FromDate string `json:"fromDate"` // MM/DD/YYYY HH:MM:SS
ToDate string `json:"toDate"` // MM/DD/YYYY HH:MM:SS
SendingInt int `json:"sendingInt"` // reply interval in minutes
Subject string `json:"subject"`
Content string `json:"content"`
SendTo string `json:"sendTo"` // "all"/"contacts"/"noncontacts"/"org"/"nonOrgAll"
}
VacationReply represents vacation auto-reply settings