Managing Aliases

Send-as aliases represent the email addresses an account can send mail from. Each account always has at least one alias to represent the primary email address of the account.

Send-as aliases correspond to the "Send mail as" feature in the web interface.

Aliases are also used to manage signatures for an account. Basic understanding of send-as aliases are required for you to be able to change email signatures. The above video shows you how to loop through send-as aliases and modify the signature for a user's primary email address.

For information on how to create, list, get, update, or delete aliases, see the SendAs reference.

Creating and verifying aliases

You must create aliases prior to use. In some cases, users must also verify ownership of the alias.

If Gmail requires user verification for an alias, the alias is returned with the status pending. A verification message is automatically sent to the target email address. The owner of the email address must complete the verification process before it can be used.

Aliases that do not require verification have a verification status of accepted.

Use the verify method to resend the verification request if needed.

SMTP settings

Aliases for external addresses should send mail through a remote SMTP mail sending agent (MSA). To configure the SMTP MSA for an alias, use the smtpMsa field to provide the connection details.

Managing signatures

You may also configure email signatures for each alias. For example, to set the signature for the user's primary address:

Java

SendAs primaryAlias = null;
ListSendAsResponse aliases = gmailService.users().settings().sendAs().list("me").execute();
for (SendAs alias: aliases.getSendAs()) {
    if (alias.getIsPrimary()) {
        primaryAlias = alias;
        break;
    }
}
SendAs aliasSettings = new SendAs().setSignature("I heart cats.");
SendAs result = gmailService.users().settings().sendAs().patch(
        "me",
        primaryAlias.getSendAsEmail(),
        aliasSettings)
        .execute();
System.out.println("Updated signature for " + result.getDisplayName());

Python

primary_alias = None
aliases = gmail_service.users().settings().sendAs().\
    list(userId='me').execute()
for alias in aliases.get('sendAs'):
    if alias.get('isPrimary'):
        primary_alias = alias
        break

sendAsConfiguration = {
    'signature': 'I heart cats'
}
result = gmail_service.users().settings().sendAs().\
    patch(userId='me',
          sendAsEmail=primary_alias.get('sendAsEmail'),
          body=sendAsConfiguration).execute()
print 'Updated signature for: %s' % result.get('displayName')

Send feedback about...