0

List Send-As Aliases

by
Published today

List the addresses the account can send from (primary address plus aliases), for the from parameter of Send Email. Requires gmail.readonly, gmail.modify or gmail.settings.basic on the connection.

Script gmail Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 hours ago
1
//native
2

3
/**
4
 * List Send-As Aliases
5
 * List the addresses the account can send mail from: the primary address plus any send-as aliases, with their display name, signature and `verificationStatus` (only `accepted` aliases can be used as `from` in Send Email). Requires gmail.readonly, gmail.modify or gmail.settings.basic on the connection.
6
 */
7
export async function main(auth: RT.Gmail) {
8
  const response = await fetch(
9
    "https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs",
10
    {
11
      headers: {
12
        Authorization: `Bearer ${auth.token}`,
13
        Accept: "application/json",
14
      },
15
    }
16
  )
17
  if (!response.ok) {
18
    throw new Error(`${response.status} ${await response.text()}`)
19
  }
20

21
  return await response.json()
22
}
23