Google Apps allows website administrators to offer their users co-branded versions of a variety of personalized Google applications, such as Google mail.
This document describes the Email Settings API which enables Google partners to programmatically manipulate most user-level Google Mail settings.
The Email Settings API supports the following operations:
To use the Email Settings API, you need to send an HTTP request to a specific URL that represents a particular user's setting. The request will be one of two types—either a POST request that performs a create operation, for creating new labels, filters, or send-as aliases—or a PUT request that performs an update operation, for changing any of the updatable settings listed above. Each URL will either support a create operation, or an update operation. Retrieve and delete operations are currently not supported.
The body of the PUT or the POST requests will contain XML that describes either the entity to be created, or the new values that the settings should take. Google will verify that all requests contain valid XML, include all required data fields, and meet the authentication requirements given below.
All of your API requests must be sent over HTTPS. Each API request that you send needs to contain an authentication token, which Google will use to authorize access to the operation specified in the API request. Authentication tokens are only available to users who have administrative rights in your domain, and those tokens only authorize operations within your domain.
The ClientLogin Interface provides additional information about programmatically logging users into their accounts.
To obtain an authentication token, submit an HTTP POST request to the following URL:
https://www.google.com/accounts/ClientLogin
The following guidelines apply to the request:
The POST body needs to include a string in the following format:
&Email=<email_address>&Passwd=<password>&accountType=HOSTED&service=apps
You will need to make the following changes to this string:
Replace the string <email_address> with the email address for your admin account.
Replace the string <password> with the password for that account.
The email address and password values must be URL-encoded. For example, the URL-encoded form of the email address apps.test.account@example.com is apps%2Etest%2Eaccount%40example%2Ecom.
The POST request must specify the value application/x-www-form-urlencoded for the Content-Type header.
Google will return a response containing your authentication token in response to your POST request. The authentication token will be the Auth value on that page, and you need to extract the token from the page. When you submit an API request, you must set the Content-type and Authorization headers as shown in the example below.
Content-type: application/atom+xml
Authorization: GoogleLogin auth=your-authentication-token
Note: Authentication tokens expire after 24 hours. As such, you will need to submit a request to the above URL at least once every 24 hours. We recommend that you keep the token in memory rather than writing it to a file.
The following Perl script demonstrates how to make an HTTP POST request for an authentication token.
#! /usr/bin/perl -w
use strict;
use LWP::UserAgent;
# Create an LWP object to make the HTTP POST request
my $lwp_object = LWP::UserAgent->new;
# Define the URL to submit the request to
my $url = 'https://www.google.com/accounts/ClientLogin';
# Submit the request with values for the Email, Passwd,
# accountType and service variables.
my $response = $lwp_object->post( $url,
[ 'accountType' => 'HOSTED',
'Email' => 'admin_email@example.com',
'Passwd' => 'admin_password',
'service' => 'apps'
]
);
die "$url error: ", $response->status_line unless $response->is_success;
# Extract the authentication token from the response
my $auth_token;
foreach my $line (split/\n/, $response->content) {
if ($line =~ m/^Auth=(.+)$/) {
$auth_token = $1;
last;
}
}
print "authentication token is $auth_token\n";
Note that to use this code, you need to replace the Email and Passwd values with the email address and password for your hosted admin account.
In order to change a user's settings with the Email Settings API, the administrator must make an HTTP request (either a POST or a PUT) to a certain URL, with an XML atom entry in the body of the request. The following sections explain the format of the request URL as well as the concept of an XML atom entry; however, for each setting you want to change, consult the specific section in this document for the exact properties to set.
The first step to changing a user's settings with the Email Settings API is to find the URL for the setting you plan to change, and whether it is accessed with a create request (a POST) or an update request (a PUT).
The example below shows the format URLs take in the Email Settings API. This particular example adds a new Google Mail filter for a user in your domain. Variables are highlighted in bold, blue text.
https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/{settingID}
The following variables should be filled in to complete the request:
The following table shows different settings which can be changed, their settingIDs, and whether they support POST (create requests) or PUT (update requests).
| Setting | settingID | POST or PUT |
|---|---|---|
| Label creation | label | POST |
| Filter creation | filter | POST |
| Send-as Alias creation | sendas | POST |
| Web clip settings | webclip | PUT |
| Forwarding settings | forwarding | PUT |
| POP settings | pop | PUT |
| IMAP settings | imap | PUT |
| Vacation Responder settings | vacation | PUT |
| Signature | signature | PUT |
| Language settings | language | PUT |
| General settings | general | PUT |
For example, to create a filter for the user alice on the example.com domain, you would submit an HTTP POST request to the following URL:
https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/alice/filter
The second step is to find the format that the XML body of the request must take. The XML document is a Google Data Atom entry. The <entry> must contain at least one <apps:property> tag. Each <apps:property> tag has a name and a value attribute which describe how the email settings are to be changed— such as describing a filter to be created, or the new values that forwarding settings should take.
The following XML example describes a fairly straightforward filter that will archive every email from the example.com domain with project 1 in the subject header.
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom'
xmlns:apps='http://schemas.example.com/apps/2006'>
<apps:property name='from' value='example.com'/>
<apps:property name='subject' value='project 1'/>
<apps:property name='shouldArchive' value='true'/>
</atom:entry>
This example does not show all of the possibilities for creating filters, or explain how to change any of the other settings. The following sections explain in full details the required XML format for each settings operation.
If the filter was created sucessfully, the Email Settings API will return an HTTP 201 response indicating a successful creation. The body of the response will echo back the create or update request.
However, if there was an error due to an invalid API request, an HTTP error response is returned. The list of possible HTTP response codes are listed at http://code.google.com/apis/gdata/reference.html#http-status-codes.
If there was an error that occurred during the creation of the filter, an XML error response is returned. The list of possible XML response codes are listed at http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#google_apps_tag_error.
The following is an example of an error that occurred during the creation of a filter:
400 BAD REQUEST
<?xml version="1.0" encoding="UTF-8"?>
<AppsForYourDomainErrors>
<error errorCode="1301" reason="EntityDoesNotExist"
invalidInput="your-invalid-input"/>
</AppsForYourDomainErrors>
There are a few potential sources of errors that system administrators should consider when using the Email Settings API.
Creating labels in Google Mail is accomplished with a POST request to the following URL:
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/label
The following table shows the only property to be set when creating a label.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| label | name="label" | value="Important" | The label to create in Google Mail | (any HTML encoded string up to 40 characters- note that the '^' character is not allowed) |
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/label
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="label" value="status updates" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.createLabel(users, "status updates");
Creating a Google Mail filter is accomplished with a POST request to the following URL:
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/filter
The following two tables shows the properties to be set when creating a filter. The first table shows what you can filter on, the second what action you can take, and their corresponding XML attributes. At least one property from the first table and one from the second table must be set.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| From | name="from" | value="jane@example.com" | The email must come from this address in order to be filtered. | (a valid email address up to 400 characters) |
| To | name="to" | value="bob@example.com" | The email must be sent to this address in order to be filtered. | (a valid email address up to 400 characters) |
| Subject | name="subject" | value="project" | A string the email must have in its subject line to be filtered. | (any HTML encoded string up to 1000 characters*) |
| Has the words | name="hasTheWord" | value="work" | A string the email can have anywhere in it's subject or body. | (any HTML encoded string up to 1000 characters*) |
| Doesn't have | name="doesNotHaveTheWord" | value="proposal" | A string that the email cannot have anywhere in its subject or body. | (any HTML encoded string up to 1000 characters*) |
| Has attachment | name="hasAttachment" | value="true" | A boolean representing whether or not the email contains an attachment. | "true" or "false" |
*Note that when specifying the subjects or the words for the filter to match, many non-alphanumeric characters cannot be used. Disallowed characters include square brackets, parentheses, currency symbols, the ampersand, the pound sign and asterisks.
| Action | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| Apply a label | name="label" | value="example.com work" | The name of the label to apply if a message matches the specified filter criteria. | (any HTML encoded string up to 40 characters- note that the '^' character is not allowed) |
| Mark as read | name="shouldMarkAsRead" | value="true" | Whether to automatically mark the message as read if it matches the specified filter criteria | "true" or "false" |
| Archive | name="shouldArchive" | value="true" | Whether to automatically move the message to "Archived" state if it matches the specified filter criteria | "true" or "false" |
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/filter
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="from" value="alice@gmail.com" />
<apps:property name="hasTheWord" value="project proposal" />
<apps:property name="shouldMarkAsRead" value="true" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.createLabel(users,
"alice@gmail.com", // from
"", // to
"", // subject
"project proposal", // hasTheWord
"", // doesNotHaveTheWord
false, // hasAttachment
true, // shouldMarkAsRead
false, // shouldArchive
""); // label
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/filter
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="to" value="announcements@example.com" />
<apps:property name="label" value="announcements" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.createLabel(users,
"", // from
"announcements@example.com", // to
"", // subject
"", // hasTheWord
"", // doesNotHaveTheWord
false, // hasAttachment
false, // shouldMarkAsRead
false, // shouldArchive
"announcements"); // label
Creating a Google Mail send-as alias is accomplished with a POST request to the following URL:
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/sendas
The following table shows the properties to be set when creating a send-as Alias.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| name | name="name" | value="Network Support" | The name that will appear in the "From" field for this user. | (any HTML encoded string up to 250 characters) |
| address | name="address" | value="support@example.com" | The email address that appears as the origination address for emails sent by this user. | (any email address which exists as a user or an alias on the hosted domain) |
| replyTo | name="replyTo" | value="fred@example.net" | (Optional) If set, this address will be included as the reply-to address in emails sent using the alias. | (any valid email address) |
| makeDefault | name="makeDefault" | value="true" | (Optional) If set to true, this alias will be become the new default alias to send-as for this user. | "true" or "false" |
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/sendas
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="name" value="Sales" />
<apps:property name="address" value="sales@example.com" />
<apps:property name="makeDefault" value="true" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.createSendAs(users,
"Sales", // name
"sales@example.com", // address
true); // makeDefault
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/sendas
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="name" value="Support" />
<apps:property name="address" value="support@example.com" />
<apps:property name="replyTo" value="b.smith@gmail.com" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.createSendAs(users,
"Support", // name
"support@example.com", // address
false); // makeDefault
Updating Google Mail web clip settings is accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/webclip
The following table shows the only property to be set when updating web clip settings.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| enable | name="enable" | value="true" | Whether to enable showing Web clips. | "true" or "false" |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/webclip
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="true" />
</atom:entry>
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/webclip
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="false" />
</atom:entry>
Updating Google Mail Forwarding settings is accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/forwarding
Note: Although an administrator can change these properties at any time, the changed settings will only take effect once the user has agreed to the terms of service.
The following table shows the properties to be set when updating forwarding settings. Note that all properties are required to enable forwarding settings (but setting enable to false is enough to disable).
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| enable | name="enable" | value="true" | Whether to enable forwarding of incoming mail. | "true" or "false" |
| forwardTo | name="forwardTo" | value="fred@example.com" | The email will be forwarded to this address. | (any valid email address) |
| action | name="action" | value="KEEP" | What Google Mail should do with its copy of the email after forwarding it on. | "KEEP" (in inbox), "ARCHIVE", or "DELETE" (send to trash) |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/forwarding
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="true" />
<apps:property name="forwardTo" value="alice@example.net" />
<apps:property name="action" value="KEEP" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changeForward(users,
true, // enable
"alice@example.com", // forwardTo
"KEEP"); // action
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/forwarding
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="true" />
<apps:property name="forwardTo" value="b.smith@gmail.com" />
<apps:property name="action" value="ARCHIVE" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.changeForward(users,
true, // enable
"b.smith@gmail.com", // forwardTo
"ARCHIVE"); // action
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/forwarding
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="false" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changeForward(users,
false, // enable
"", // forwardTo
""); // action
Updating Google Mail POP settings is accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/pop
Note: Although an administrator can change these properties at any time, the changed settings will only take effect once the user has agreed to the terms of service.
The following table shows the properties to be set when updating POP settings. Note that all properties are required to enable POP settings (but setting enable to false is enough to disable).
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| enable | name="enable" | value="true" | Whether to enable POP3 access. | "true" or "false" |
| enableFor | name="enableFor" | value="ALL_MAIL" | Whether to enable POP3 for all mail, or mail from now on. | "ALL_MAIL", "MAIL_FROM_NOW_ON" |
| action | name="action" | value="KEEP" | What Google Mail should do with its copy of the email after it is retrieved using POP. | "KEEP" (in inbox), "ARCHIVE", or "DELETE" (send to trash) |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/pop
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="true" />
<apps:property name="enableFor" value="MAIL_FROM_NOW_ON" />
<apps:property name="action" value="KEEP" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changePop(users,
true, // enable
"MAIL_FROM_NOW_ON", // enableFor
"KEEP"); // action
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/pop
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="true" />
<apps:property name="enableFor" value="ALL_MAIL" />
<apps:property name="action" value="DELETE" />
</atom:entry>
<
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.changePop(users,
true, // enable
"ALL_MAIL", // enableFor
"DELETE"); // action
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/pop
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="false" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changePop(users,
false, // enable
"", // enableFor
""); // action
Updating Google Mail IMAP settings is accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/imap
Note: Although an administrator can change these properties at any time, the changed settings will only take effect once the user has agreed to the terms of service.
The following table shows the only property to be set when updating IMAP settings.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| enable | name="enable" | value="true" | Whether to enable IMAP access. | "true" or "false" |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/imap
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="true" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.changeImap(users, true); // enable
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/imap
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="false" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.changeImap(users, false); // enable
Updating Google Mail Vacation-responder settings is accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/vacation
The following table shows the properties to be set when updating Vacation-responder settings.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| enable | name="enable" | value="true" | Whether to enable the vacation responder. | "true" or "false" |
| subject | name="subject" | value="On vacation!" | The subject line of the vacation responder autoresponse. | (any HTML encoded string up to 500 characters) |
| message | name="message" | value="I won't be checking email until the 28th." | The message body of the vacation responder autoresponse.. | (any HTML encoded string up to 100 KB of characters) |
| contactsOnly | name="contactsOnly" | value="true" | Whether to only send the autoresponse to known contacts. | "true" or "false" |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/ben/vacation
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="true" />
<apps:property name="subject" value="Out of office" />
<apps:property name="message" value="If it's urgent you can contact me on 555-5555." />
<apps:property name="contactsOnly" value="true" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.changeVacation(users,
true, // enable
"Out of office", // subject
"If it's urgent you can contact me on 555-5555.", // message
true); // contactOnly
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/vacation
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="enable" value="false" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changeVacation(users,
false, // enable
"", // subject
"", // message
false); // contactOnly
Updating the Google Mail signature is accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/signature
The following table shows the only property to be set when updating the signature.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| signature | name="signature" | value="Regards, Joe." |
The signature to be appended to outgoing messages.
|
(any HTML encoded string up to 1000 characters) |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/signature
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="signature" value="Liz Jones - (+1) 619-555-5555
Accounts Management, A&Z LTD." />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"ben"};
service.changeSignature(users,
"Liz Jones - (+1) 619-555-5555\n" +
"Accounts Management, A&Z LTD."); // signature
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/signature
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="signature" value="" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changeSignature(user, ""); // signature
Updating the display language setting in Google Mail can be accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/language
The following table shows the only property to be set when updating the display language.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| language | name="language" | value="en-US" | Google Mail's display language | Language Tag according to RFC 3066, for any language that Google Mail supports. e.g. "en-GB", "fr" or "ja" for British English, French, or Japanese See complete list below. |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/language
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="language" value="de" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changeLanguage(users, "de"); // language
| English name for language | Language (as displayed in Google Mail) | RFC 3066 Language Tag accepted by Google Mail |
|---|---|---|
| Arabic | العربية | ar |
| Bengali | বাংলা | bn |
| Bulgarian | Български | bg |
| Catalan | Català | ca |
| Chinese (Simplified) | 中文(简体) | zh-CN |
| Chinese (Traditional) | 中文(繁體) | zh-TW |
| Croatian | Hrvatski | hr |
| Czech | Český | cs |
| Danish | Dansk | da |
| Dutch | Nederlands | nl |
| English (United States) | English (US) | en-US |
| English (United Kingdom) | English (UK) | en-GB |
| Estonian | Eesti keel | et |
| Finnish | Suomi | fi |
| French | Français | fr |
| German | Deutsch | de |
| Greek | Ελληνικά | el |
| Gujarati | ગુજરાતી | gu |
| Hebrew | עברית | iw |
| Hindi | हिन्दी | hi |
| Hungarian | Magyar | hu |
| Icelandic | Íslenska | is |
| Indonesian | Bahasa Indonesia | in |
| Italian | Italiano | it |
| Japanese | 日本語 | ja |
| Kannada | ಕನ್ನಡ | kn |
| Korean | 한국어 | ko |
| Latvian | Latviešu | lv |
| Lithuanian | Lietuvių | lt |
| Malay | Bahasa Melayu | ms |
| Malayalam | മലയാളം | ml |
| Marathi | मराठी | mr |
| Norwegian | Norsk (Bokmål) | no |
| Oriya | ଓଡିଆ (Oriya) | or |
| Persian | فارسی | fa |
| Polish | Polski | pl |
| Portuguese (Brazil) | Português (Brasil) | pt-BR |
| Portuguese (Portugal) | Português (Portugal) | pt-PT |
| Romanian | Română | ro |
| Russian | Русский | ru |
| Serbian | Српски | sr |
| Slovak | Slovenský | sk |
| Slovenian | Slovenščina | sl |
| Spanish | Español | es |
| Swedish | Svenska | sv |
| Tagalog | Filipino | tl |
| Tamil | தமிழ் | ta |
| Telugu | తెలుగు | te |
| Thai | ภาษาไทย | th |
| Turkish | Türkçe | tr |
| Ukrainian | Українська | uk |
| Urdu | اردو | ur |
| Vietnamese | Tiếng Việt | vi |
Updating various Google Mail General settings can be accomplished with a PUT request to the following URL:
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain}/{username}/general
The following table shows the properties to be set when updating general settings. A request should contain at least one of these properties, but need not contain all five.
| Name | XML attribute | example XML value | Description | Possible values |
|---|---|---|---|---|
| pageSize | name="pageSize" | value="50" | The number of conversations to be shown per page. | "25", "50" or "100" |
| shortcuts | name="shortcuts" | value="true" | Whether to enable keyboard shortcuts | "true" or "false" |
| arrows | name="arrows" | value="true" | Whether to display arrow-shaped personal indicators next to emails that were sent specifically to the user. ( › and » ) | "true" or "false" |
| snippets | name="snippets" | value="true" | Whether to display snippets of messages in the inbox and when searching. | "true" or "false" |
| unicode | name="unicode" | value="true" | Whether to use UTF-8 (unicode) encoding for all outgoing messages, instead of the default text encoding. | "true" or "false" |
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/general
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="pageSize" value="25" />
<apps:property name="arrows" value="true" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changeGeneral(users,
"25", // pageSize
false, // shortcuts
true, // arrows
false, // snippets
false); // unicode
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/liz/general
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="shortcuts" value="false" />
</atom:entry>
import sample.appsforyourdomain.gmailsettings;
...
GmailSettings service = new GmailSettings("your-apps", "yourdomain", "adminUsername", "adminPassword");
String[] users = new String[] {"liz"};
service.changeGeneral(users,
"25", // pageSize
true, // shortcuts
false, // arrows
false, // snippets
false); // unicode
PUT https://apps-apis.google.com/a/feeeds/emailsettings/2.0/example.com/johndoe/language
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="language" value="ko" />
</atom:entry>
ResponseHTTP/1.1 302 Found Connection: Close Location: http://www.google.com Content-Type: text/html; charset=UTF-8 <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> <TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> The document has moved <A HREF="http://www.google.com">here</A>. </BODY></HTML>
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/invaliduser/language
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="language" value="ko" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/xml <?xml version="1.0" encoding="UTF-8"?> <AppsForYourDomainErrors> <error errorCode="1301" invalidInput="" reason="EntityDoesNotExist" /> </AppsForYourDomainErrors>
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/language
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="language" value="ko" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/plain; charset=UTF-8 Invalid request URI.
PUT https://apps-apis.google.com/a/feeds/user/1.0/example.com/johndoe/language
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="language" value="ko" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/plain; charset=UTF-8 Invalid request URI.
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/language
<!-- missing XML. -->
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/plain; charset=UTF-8 Premature end of file.
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/vacation
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<!-- Property "enable" is missing. -->
<apps:property name="subject" value="Out of office" />
<apps:property name="message" value="If it's urgent you can contact me on 555-5555." />
<apps:property name="contactsOnly" value="true" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/plain; charset=UTF-8 Required field missing: enable
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/sendas
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<!-- Property "name" is missing. -->
<apps:property name="address" value="sales@example.com" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/plain; charset=UTF-8 Required field missing: name
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/filter
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="from" value="alice@gmail.com" />
<apps:property name="hasTheWord" value="project proposal" />
<apps:property name="shouldMarkAsRead" value="true" />
<apps:property name="label" value="01234567890123456789012345678901234567890" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/plain; charset=UTF-8 Must be at most 40 characters: label
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/filter
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="from" value="alice@gmail.com" />
<apps:property name="hasTheWord" value="project proposal" />
<aapps:property name="shouldMarkAsRead" value="true" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/plain; charset=UTF-8 The prefix "aapps" for element "aapps:property" is not bound.
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/sendas
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="name" value="Sales" />
<apps:property name="address" value="invaliduser@example.com" />
</atom:entry>
ResponseHTTP/1.1 400 Bad Request Connection: Close Content-Type: text/xml <?xml version="1.0" encoding="UTF-8"?> <AppsForYourDomainErrors> <error errorCode="1301" invalidInput="invaliduser@example.com" reason="EntityDoesNotExist" /> </AppsForYourDomainErrors>
POST https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/filter
<!-- no authorization token was sent with this request -->
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="from" value="alice@gmail.com" />
<apps:property name="hasTheWord" value="project proposal" />
<apps:property name="shouldMarkAsRead" value="true" />
</atom:entry>
ResponseHTTP/1.1 401 (Unauthorized) Unknown authorization header Connection: Close Content-Type: text/html; charset=UTF-8 <HTML> <HEAD> <TITLE>Unknown authorization header</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Unknown authorization header</H1> <H2>Error 401</H2> </BODY> </HTML>
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/invaliddomain.com/johndoe/language
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="language" value="ko" />
</atom:entry>
ResponseHTTP/1.1 403 (Forbidden) You are not authorized to perform operations on the domain invaliddomain.com. <HTML> <HEAD> <TITLE>You are not authorized to perform operations on the domain invaliddomain.com.</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>You are not authorized to perform operations on the domain invaliddomain.com.</H1> <H2>Error 403</H2> </BODY> </HTML>or
HTTP/1.1 403 (Forbidden) Domain cannot use API Connection: Close Content-Type: text/html; charset=UTF-8 <HTML> <HEAD> <TITLE>Domain cannot use API</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Domain cannot use API</H1> <H2>Error 403</H2> </BODY> </HTML>
PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/johndoe/language
<!-- Content-Type should be "application/atom+xml" -->
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:apps="http://schemas.google.com/apps/2006">
<apps:property name="language" value="ko" />
</atom:entry>
ResponseHTTP/1.1 415 Unsupported Media Type Connection: Close Content-Type: text/plain; charset=UTF-8 Content-Type text/html;charset=UTF-8 is not valid.