PHPackages                             moometric/gsuite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. moometric/gsuite

ActiveLibrary[API Development](/categories/api)

moometric/gsuite
================

Simple PHP library to manage GSuite users signatures

1.0.3(7y ago)43807↓50%19[6 issues](https://github.com/moometric/GSuiteSignatureManager/issues)MITPHPPHP &gt;=5.3.0

Since Mar 6Pushed 7y ago5 watchersCompare

[ Source](https://github.com/moometric/GSuiteSignatureManager)[ Packagist](https://packagist.org/packages/moometric/gsuite)[ Docs](https://github.com/moometric/GSuiteSignatureManager)[ RSS](/packages/moometric-gsuite/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

[![Packagist](https://camo.githubusercontent.com/f58620001d70a506b20514928dbcba15b36a344b3f72a111b40e2164a2e715ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f6f6d65747269632f6773756974652e7376673f6d61784167653d33363030)](https://github.com/moometric/GSuiteSignatureManager/) [![Version](https://camo.githubusercontent.com/449427e1ecb052967692c6ad1e48204eaec709a78b11dfe371910d2bda936c0e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6f6d65747269632f4753756974652e7376673f7374796c653d666c6174266d61784167653d33363030)](https://packagist.org/packages/moometric/GSuite) [![License](https://camo.githubusercontent.com/e498eead712d82d9ee1af0a4850acd2e46ea48c48fb9ce5a3d2ab64f28f95b34/687474703a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e737667)](http://doge.mit-license.org)

GSuite Signature Manager (PHP)
==============================

[](#gsuite-signature-manager-php)

Ensure that all your users have a standard signature by updating them using the gmail API. Users signatures can be updated direct from the GSuite users directory using standard and custom fields or alternatively from a JSON users file.

[![alt text](https://raw.githubusercontent.com/moometric/GSuiteSignatureManager/master/sig.png "GSuite Signature Manager")](https://raw.githubusercontent.com/moometric/GSuiteSignatureManager/master/sig.png)

- **defaultSig.html** template is included, you can add your own templates to the "signatures" directory.
- **testUsers.json** JSON file is included as an example when fetching users from local source rather than GSuite domain.
- Fetch users direct from GSuite directory including all attributes (Full name, phone number, profile photo, etc...).
- Support for auto fetching and mapping of GSuite directory custom attributes to merge tags for use in email signatures.

Getting Started
---------------

[](#getting-started)

### Prerequisites

[](#prerequisites)

- You are a GSuite domain admin with full super admin access
- Make sure your are running at least PHP 5.4+
- Your PHP server can read files from the **local\_vars** and **signatures** directory (after installing)

### Installing

[](#installing)

#### Step 1: Create your service account

[](#step-1-create-your-service-account)

Ensure that you have gone through the steps *[described here](https://moometric.com/integrations/gsuite/use-gmail-api-update-signatures-gsuite-users-php/#Setup_the_gmail_API)* to get your **service-account.json** file. More information can be found on the [Google Admin SDK Guide](https://developers.google.com/admin-sdk/directory/v1/guides/delegation#create_the_service_account_and_its_credentials) to setting up a service account for your GSuite domain.

```
Copy your service-account.json file into the local_vars directory

```

#### Step 2: Grant Domain Wide Delegation

[](#step-2-grant-domain-wide-delegation)

Ensure that you have *[granted domain wide delegation](https://developers.google.com/admin-sdk/directory/v1/guides/delegation#delegate_domain-wide_authority_to_your_service_account)* through the GSuite console for the following scopes of your service account

```
https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.user.alias', 'https://www.googleapis.com/auth/admin.directory.userschema','https://www.googleapis.com/auth/gmail.settings.basic','https://www.googleapis.com/auth/gmail.settings.sharing

```

#### Step 3: Install or clone this repo

[](#step-3-install-or-clone-this-repo)

```
composer require moometric/gsuite

```

OR

```
git clone https://github.com/moometric/GSuiteSignatureManager.git

```

#### Step 4: Update your signature template

[](#step-4-update-your-signature-template)

By default there is a signature template located in **"signatures/defaultSig.html"**. You can modify this template and include your own MERGE fields.

Merge fields are in the following format **{{mergeFieldOne}}**. If you're not sure what merge fields you can use, use *[listMergeFields()](#user-content-see-a-list-of-available-merge-tags)* function to view a list of available merge tags.

#### Step 5: Instantiate the signature object

[](#step-5-instantiate-the-signature-object)

If using composer, don't forget to include your autoload file.

```
require_once '/path/to/your-project/vendor/autoload.php';
```

```
use Moometric\mooSignature;
$mooSig = new mooSignature("primaryDomain.com", "adminEmail@primaryDomain.com");
// Optionally set the path where your default service-account.json file is stored.
$mooSig->addSettingServiceAccountPath("/your/project/path/local_vars/");
// Optionally set the path where your signatures are stored.
$mooSig->addsettingSignaturePath("/your/project/path/signatures/");
```

### Testing

[](#testing)

Included is an **index.php** file which contains a few tests to get started.

Once you go live, ensure that you switch off testing mode.

```
$mooSig->addSettingRunTestMode(False);
```

Usage Examples
--------------

[](#usage-examples)

### **Message of the day**

[](#message-of-the-day)

#### Set/Update the MOTD for all GSuite users

[](#setupdate-the-motd-for-all-gsuite-users)

This will set "Hello World" as the MOTD for all GSuite users

```
$mooSig->addSettingMOTDHTML("Hello World");
$mooSig->addSettingMOTDPosition("Below");
$mooSig->addSettingMOTD(True);
$mooSig->setSignatureMOTD();
```

#### Removing the MOTD for all GSuite users

[](#removing-the-motd-for-all-gsuite-users)

If exists, this will remove MOTD for all GSuite users

```
$mooSig->removeSignatureMOTD();
```

#### Set/Update/Remove MOTD for select GSuite users

[](#setupdateremove-motd-for-select-gsuite-users)

If you only want certain GSuite users to have a MOTD, you can filter the users by their primary email.

```
$mooSig->addSettingMOTDHTML("Marketing Department MOTD");
$mooSig->addSettingFilterEmailsToUpdate(["fakeEmail@moometric.com", "anotherEmail@moometric.com"]);
$mooSig->setSignatureMOTD();
```

Or remove MOTD from those same select users

```
$mooSig->removeSignatureMOTD();
```

### **Updating the signature**

[](#updating-the-signature)

#### Update signature for all domain users

[](#update-signature-for-all-domain-users)

Update the signature for all domain users from the default template.

```
$mooSig->addSettingSetTemplate("defaultSig.html");
$mooSig->updateSignatures();
```

#### Update signature for all domain users and set MOTD

[](#update-signature-for-all-domain-users-and-set-motd)

Update the signature for all domain users from the default template.

```
$mooSig->addSettingMOTDHTML("Hello World");
$mooSig->updateSignatures();
```

#### Update signature for only certain users or single user

[](#update-signature-for-only-certain-users-or-single-user)

Update the signature for all domain users from the default template. In the example below only ** and ** will be updated, all other users will be excluded

```
$mooSig->addSettingFilterEmailsToUpdate(["fakeEmail@moometric.com", "anotherEmail@moometric.com"]);
$mooSig->updateSignatures();
```

#### Exclude users who don't have their profile photo set

[](#exclude-users-who-dont-have-their-profile-photo-set)

Update the signature for all domain users but exclude those who don't have a profile photo or title set.

```
$mooSig->addSettingSkipConditions(["title", "thumbnailPhotoUrl"]);
$mooSig->updateSignatures();
```

#### Update signature for users in a JSON file

[](#update-signature-for-users-in-a-json-file)

Update the signature for users in the JSON file *testUsers.json*.

```
$mooSig->addSettingUsersFile("testUsers.json");
$mooSig->updateSignatures();
```

#### Update signature for users in your own array

[](#update-signature-for-users-in-your-own-array)

In this example only users who are in the array below will be updated with a new signature. Two users below will be updated.

```
$mooSig->addSettingUserArray([
	[
		"primaryEmail" => "fakeEmail@moometric.com",
		"alias" => "fakeEmail@moometric.com",
		"fullName" => "MooMaster",
	],
	[
		"primaryEmail" => "anotherEmail@moometric.com",
		"alias" => "anotherEmail@moometric.com",
		"fullName" => "MooMinor",
	]
]);
$mooSig->updateSignatures();
```

### **Other examples**

[](#other-examples)

#### See a list of available merge tags

[](#see-a-list-of-available-merge-tags)

If you want to see what merge fields are available for use in your template, you can run the following function to echo and output to your browser.

```
$mooSig->listMergeFields();
```

**Output will look something like this**

Merge TagExample{{primaryEmail}}fakeEmail@moometric.com{{alias}}fakeEmail@moometric.com{{thumbnailPhotoUrl}}{{fullName}}MooMaster{{phone0}}555-555-555{{title}}IT Admin / DeveloperSettings
--------

[](#settings)

### **Path Settings**

[](#path-settings)

If your signature, service-account.json or user defined JSON file aren't stored in the default directories, you can use the following to set the path where your files are located.

#### Set the service-account.json path *(Default - /local-vars/)*

[](#set-the-service-accountjson-path-default---local-vars)

Set the directory where your *service-account.json* file is stored

```
$mooSig->addSettingServiceAccountPath("/your/project/path/local_vars/");
```

#### Set the signatures path *(Default - /signatures/)*

[](#set-the-signatures-path-default---signatures)

Set the directory where your signatures are stored

```
$mooSig->addsettingSignaturePath("/your/project/path/signatures/");
```

#### Set the users file path *(Default - /local-vars/)*

[](#set-the-users-file-path-default---local-vars)

Set the directory where your users json files are stored. This is only required if you are fetching your users from a local JSON file, rather than the GSuite directory.

```
$mooSig->addSettingJSONPath("/your/project/path/local_vars/");
```

### **Basic Settings**

[](#basic-settings)

#### Run test mode *(Default - True)*

[](#run-test-mode-default---true)

During test mode no signatures are updated

```
$mooSig->addSettingRunTestMode(True);
```

#### Preview the output HTML *(Default - True)*

[](#preview-the-output-html-default---true)

When testing, echo the signature into your browser

```
$mooSig->addSettingPreviewSignature(True);
```

#### Get users from GSuite *(Default - True)*

[](#get-users-from-gsuite-default---true)

Rather than JSON or other array. Default is True. Will default to False if you use specify a JSON array or another array source after this flag has been set.

```
$mooSig->addSettingGetUsersFromGsuite(True);
```

#### Set the template *(Default - defaultSig.html)*

[](#set-the-template-default---defaultsightml)

you wish to use that is located in the subfolder "/signatures"

```
mooSig->addSettingSetTemplate("defaultSig.html");
```

#### Strip unused tags *(Default = True)*

[](#strip-unused-tags-default--true)

that start and end with '{{' '}}' when generating the template. Switch to False when debugging.

```
$mooSig->addSettingStripBlanks(True);
```

### **User Filters**

[](#user-filters)

#### Skip fields *(Default = \[\])*

[](#skip-fields-default--)

Skip updates if any of the fields are NULL, BLANK or don't exist. Useful when updating users that might have blank values that need to be updated before their signature is created. In the example below, we're skipping the signature update for users that don't have their title or profile picture set.

```
$mooSig->addSettingSkipConditions(["title", "thumbnailPhotoUrl"]);
```

#### Filter email addresses to update *(Default = \[\])*

[](#filter-email-addresses-to-update-default--)

Enter the primaryEmail addresses that you wish you update. Any emails that aren't included here won't be updated.

```
$mooSig->addSettingFilterEmailsToUpdate(["fakeEmail@moometric.com", "anotherEmail@moometric.com"]);
```

#### Unset all current filters

[](#unset-all-current-filters)

If filters have been applied, you can unset them all using the following. Useful if you're chaining a whole heap of bulk updates with many different changing filters

```
$mooSig->addSettingUnsetFilters();
```

### **MOTD Message of the day Settings**

[](#motd-message-of-the-day-settings)

#### Set MOTD position *(Default = "Below")*

[](#set-motd-position-default--below)

Set where the MOTD appears (Above or Below) on the signature.

```
$mooSig->addSettingMOTDPosition("Below");
```

#### Set HTML for MOTD *(Default = "")*

[](#set-html-for-motd-default--)

String value of the HTML that you want to include in the email signature.

```
$mooSig->addSettingMOTDHTML("Hello World");
```

#### Set MOTD when generating template *(Default = True)*

[](#set-motd-when-generating-template-default--true)

If you don't set the MOTD HTML, this will have no effect. Otherwise when the template for a user is generated, the MOTD will be included upon generation.

```
$mooSig->addSettingMOTD(True);
```

### **Other Settings**

[](#other-settings)

#### Get users from array *(Default = \[\])*

[](#get-users-from-array-default--)

If you would prefer to get the users details from an array rather than the GSuite directory, you can push your own custom users array along with all the details for the signatures you wish to update. For this option you must include the **primaryEmail** and **alias** in each user array.

```
$mooSig->addSettingUserArray([
	[
		"primaryEmail" => "fakeEmail@moometric.com",
		"alias" => "fakeEmail@moometric.com",
		"thumbnailPhotoUrl" => "http://i.imgur.com/mmvUt5x.png",
		"fullName" => "MooMaster",
		"phone0" => "555-555-555",
		"title" => "IT Admin / Developer"
	],
	[
		"primaryEmail" => "anotherEmail@moometric.com",
		"alias" => "anotherEmail@moometric.com",
		"thumbnailPhotoUrl" => "http://i.imgur.com/mmvUt5x.png",
		"fullName" => "MooMinor",
		"phone0" => "444-444-444",
		"title" => "DevOps Admin"
	]
]);
```

#### Get users from JSON file *(Default = "")*

[](#get-users-from-json-file-default--)

If you would prefer to get the users details from a JSON file rather than the GSuite directory, you can add your JSON file to the */local\_vars* folder instead. For this option you must include the **primaryEmail** and **alias** in each JSON object.

```
$mooSig->addSettingUsersFile("testUsers.json");
```

**Example JSON File**

```
[
	{
		"primaryEmail": "fakeEmail@moometric.com",
		"alias": "fakeEmail@moometric.com",
		"thumbnailPhotoUrl": "http://i.imgur.com/mmvUt5x.png",
		"fullName": "MooMaster",
		"phone0": "555-555-555",
		"title": "IT Admin / Developer"
	},
	{
		"primaryEmail": "anotherEmail@moometric.com",
		"alias": "anotherEmail@moometric.com",
		"thumbnailPhotoUrl": "http://i.imgur.com/mmvUt5x.png",
		"fullName": "MooMinor",
		"phone0": "444-444-444",
		"title": "DevOps Admin"
	}
]
```

Authors
-------

[](#authors)

- MooMaster - *initial work* - [Moometric.com](https://moometric.com/)

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/moometric/GSuiteSignatureManager/blob/master/LICENSE) file for details

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Total

4

Last Release

2789d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4c7297cc4df30b4e29317a7f78a33e5d5f44831535e6c6fcba85166f543d517?d=identicon)[moometric](/maintainers/moometric)

---

Top Contributors

[![moometric](https://avatars.githubusercontent.com/u/15805783?v=4)](https://github.com/moometric "moometric (20 commits)")

---

Tags

gmail-apigoogle-admin-sdkgoogle-apigsuitesignatureapisignaturegmailgsuite

### Embed Badge

![Health badge](/badges/moometric-gsuite/health.svg)

```
[![Health](https://phpackages.com/badges/moometric-gsuite/health.svg)](https://phpackages.com/packages/moometric-gsuite)
```

###  Alternatives

[dacastro4/laravel-gmail

Gmail API package for Laravel

312382.9k1](/packages/dacastro4-laravel-gmail)[hitrov/oci-api-php-request-sign

This package generates proper HTTP headers to sign Oracle Cloud Infrastructure API requests

231.4M4](/packages/hitrov-oci-api-php-request-sign)[delatbabel/apisecurity

API Security Helpers.

1378.1k](/packages/delatbabel-apisecurity)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1243.1k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
