gmail

package
v1.77.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const Domain = "gmail.googleapis.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...gmail_config.Option) *Client

func (*Client) CreateFilter

func (c *Client) CreateFilter(ctx context.Context, userId string, f *filter.Filter, options ...fetch_config.Option) (*filter.Filter, error)

CreateFilter creates a filter for the given user.

func (*Client) CreateForwardingAddress added in v1.75.0

func (c *Client) CreateForwardingAddress(
	ctx context.Context,
	userId string,
	f *forwarding_address.ForwardingAddress,
	options ...fetch_config.Option,
) (*forwarding_address.ForwardingAddress, error)

CreateForwardingAddress registers a forwarding address for the given user. An address outside the user's domain comes back pending, and Gmail mails it a confirmation that someone there has to act on.

func (*Client) CreateLabel added in v1.61.0

func (c *Client) CreateLabel(
	ctx context.Context,
	userId string,
	l *label.Label,
	options ...fetch_config.Option,
) (*label.Label, error)

CreateLabel adds a label to the mailbox and returns it with its id.

Creating one that already exists is answered 409 by Gmail rather than returning the existing label, so a caller that wants "ensure it is there" lists first.

func (*Client) CreateSendAs

func (c *Client) CreateSendAs(ctx context.Context, userId string, s *send_as.SendAs, options ...fetch_config.Option) (*send_as.SendAs, error)

CreateSendAs creates a custom "from" send-as alias for the given user.

func (*Client) DeleteFilter

func (c *Client) DeleteFilter(ctx context.Context, userId string, filterId string, options ...fetch_config.Option) error

DeleteFilter deletes a filter identified by filterId for the given user.

func (*Client) DeleteForwardingAddress added in v1.75.0

func (c *Client) DeleteForwardingAddress(
	ctx context.Context,
	userId string,
	forwardingEmail string,
	options ...fetch_config.Option,
) error

DeleteForwardingAddress deletes the forwarding address forwardingEmail for the given user, and revokes its verification.

func (*Client) DeleteSendAs

func (c *Client) DeleteSendAs(ctx context.Context, userId string, sendAsEmail string, options ...fetch_config.Option) error

DeleteSendAs deletes a send-as alias identified by sendAsEmail for the given user.

func (*Client) GetFilter

func (c *Client) GetFilter(ctx context.Context, userId string, filterId string, options ...fetch_config.Option) (*filter.Filter, error)

GetFilter retrieves a filter identified by filterId for the given user.

func (*Client) GetForwardingAddress added in v1.75.0

func (c *Client) GetForwardingAddress(
	ctx context.Context,
	userId string,
	forwardingEmail string,
	options ...fetch_config.Option,
) (*forwarding_address.ForwardingAddress, error)

GetForwardingAddress retrieves the forwarding address forwardingEmail for the given user.

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, userId string, messageId string, options ...get_message_config.Option) (*message.Message, error)

GetMessage retrieves a message identified by messageId for the given user.

func (*Client) GetProfile added in v1.62.0

func (c *Client) GetProfile(ctx context.Context, userId string, options ...fetch_config.Option) (*profile.Profile, error)

ListLabels returns every label in the mailbox.

A label is applied by id, and a user-created label's id is opaque, so this is how a caller finds the id of a label it knows only by name. GetProfile retrieves the mailbox's profile, which is how to ask where its history stands now.

That is the one question a history listing cannot answer for the caller who needs it most: reading history requires a start id still inside Gmail's window, and a caller whose stored cursor has fallen outside it is told only that it is gone. This is where such a caller starts again from.

func (*Client) GetSendAs

func (c *Client) GetSendAs(ctx context.Context, userId string, sendAsEmail string, options ...fetch_config.Option) (*send_as.SendAs, error)

GetSendAs retrieves a send-as alias identified by sendAsEmail for the given user.

func (*Client) ListFilters

func (c *Client) ListFilters(ctx context.Context, userId string, options ...fetch_config.Option) ([]*filter.Filter, error)

ListFilters retrieves all filters for the given user.

func (*Client) ListForwardingAddresses added in v1.75.0

func (c *Client) ListForwardingAddresses(
	ctx context.Context,
	userId string,
	options ...fetch_config.Option,
) ([]*forwarding_address.ForwardingAddress, error)

ListForwardingAddresses retrieves all forwarding addresses for the given user.

func (*Client) ListHistory

func (c *Client) ListHistory(ctx context.Context, userId string, startHistoryId string, options ...list_history_config.Option) ([]*history.Record, error)

ListHistory retrieves all history records for the given user after the specified startHistoryId.

func (*Client) ListLabels added in v1.61.0

func (c *Client) ListLabels(ctx context.Context, userId string, options ...fetch_config.Option) ([]*label.Label, error)

func (*Client) ListMessages

func (c *Client) ListMessages(ctx context.Context, userId string, options ...list_messages_config.Option) ([]*message.Message, error)

ListMessages retrieves all messages for the given user matching the optional query, following the paging to the end. Only message IDs and thread IDs are populated; use GetMessage to retrieve the full message.

Spam and trash are left out unless WithIncludeSpamTrash asks for them, as Gmail leaves them out: a caller taking stock of everything a mailbox holds wants them, and one reading the inbox does not.

func (*Client) Modify added in v1.61.0

func (c *Client) Modify(
	ctx context.Context,
	userId string,
	messageId string,
	request *modify_request.Request,
	options ...fetch_config.Option,
) (*message.Message, error)

Modify changes which labels a message carries. Requires the gmail.modify scope (or wider).

It is how a service marks what it has done with a message, which is the one record the mailbox keeps and a database cannot: a database knows what it ingested, and says nothing about what arrived and was never read.

A request naming no label is refused. Gmail accepts it and changes nothing, so the call would succeed while doing none of what the caller meant.

func (*Client) ModifyThread added in v1.61.0

func (c *Client) ModifyThread(
	ctx context.Context,
	userId string,
	threadId string,
	request *modify_request.Request,
	options ...fetch_config.Option,
) (*thread.Thread, error)

ModifyThread changes which labels every message in a thread carries.

The same call as Modify against the conversation rather than one message, which is what to use when what was decided applies to the exchange and not to a single arrival.

func (*Client) Send

func (c *Client) Send(ctx context.Context, userId string, msg *message.Message, options ...fetch_config.Option) (*message.Message, error)

Send sends the specified message to the recipients in the To, Cc, and Bcc headers. The message should have its Raw field set to a base64url-encoded RFC 2822 email.

func (*Client) Trash

func (c *Client) Trash(ctx context.Context, userId string, messageId string, options ...fetch_config.Option) (*message.Message, error)

Trash moves the given message to the user's trash. Requires the gmail.modify scope (or wider).

func (*Client) UpdateSendAs

func (c *Client) UpdateSendAs(ctx context.Context, userId string, sendAsEmail string, s *send_as.SendAs, options ...fetch_config.Option) (*send_as.SendAs, error)

UpdateSendAs updates a send-as alias identified by sendAsEmail for the given user.

func (*Client) Watch

Watch sets up or renews a push notification watch on the given user's mailbox. Notifications are delivered to the Cloud Pub/Sub topic specified in the request's TopicName.

Directories

Path Synopsis
types
profile
Package profile is a Gmail mailbox's own account of itself.
Package profile is a Gmail mailbox's own account of itself.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL