You can install the extension from a local source into a Firebase project without publishing it to the Extensions Hub.
- Firebase CLI installed
- A Google account with access to the Firebase Console
If you don't already have a Firebase project to test with, create one:
- Go to the Firebase Console and click Add project.
- Enter a project name (e.g.
my-extension-test), follow the prompts, and click Create project. - Once created, upgrade to the Blaze (pay-as-you-go) plan — this is required for extensions and Cloud Functions. Click the Upgrade button in the bottom-left of the console, then link or create a billing account.
- In the Firebase Console, go to Build > Firestore Database in the left sidebar.
- Click Create database.
- Choose a database location (e.g.
nam5for multi-region US, oreur3for multi-region EU). Take note of this value — you'll need it forDATABASE_LOCATIONlater. - Start in test mode for development (this allows open read/write access for 30 days).
You'll need the project ID and Firebase config for client SDK usage:
- In the Firebase Console, click the gear icon next to "Project Overview" and select Project settings.
- The Project ID is shown near the top — you'll use this in
.firebaserc. - Under Your apps, click the web icon (
</>) to register a web app if you haven't already. Give it a nickname and click Register app. - Copy the
firebaseConfigobject shown — you'll use this when initializing the client SDK.
mkdir my-extension-test && cd my-extension-testCreate .firebaserc to link to your Firebase project:
{
"projects": {
"default": "your-firebase-project-id"
}
}Create firebase.json with the extension pointing to your local source:
{
"extensions": {
"mailtrap-email": "../mailtrap-firebase"
}
}Adjust the path to point to wherever your local copy of this extension lives.
Create the extensions/ directory and a parameter file:
mkdir extensionsCreate extensions/mailtrap-email.env:
MAILTRAP_API_TOKEN=your-mailtrap-api-token
FUNCTION_LOCATION=us-central1
DATABASE_LOCATION=nam5
MAIL_COLLECTION=mail
DEFAULT_FROM_EMAIL=noreply@your-verified-domain.com
DEFAULT_FROM_NAME=Test App
- MAILTRAP_API_TOKEN — your Mailtrap API token from the API Tokens page.
- FUNCTION_LOCATION — the Cloud Functions region to deploy to.
- DATABASE_LOCATION — the region of your Firestore database. For multi-region US use
nam5, for multi-region EU useeur3. See the Firestore locations guide. - MAIL_COLLECTION — the Firestore collection the extension watches for new documents (default:
mail). - DEFAULT_FROM_EMAIL — default sender email address. Must be from a verified sending domain in Mailtrap.
- DEFAULT_FROM_NAME — default sender display name (optional).
firebase deploy --only extensions --forceThis uploads the local extension source, builds it, and deploys it to your Firebase project. The --force flag skips interactive confirmation prompts.
You can trigger the extension by adding a document to your mail collection. There are two ways to do this:
- In the Firebase Console, go to Build > Firestore Database.
- Click Start collection (or select an existing
mailcollection if one exists). - Set the Collection ID to
mail(or whatever you configured asMAIL_COLLECTION). - Click Next to create the first document. Leave the Document ID on Auto-ID.
- Add the following fields:
| Field | Type | Value |
|---|---|---|
subject |
string | Test email |
text |
string | Hello from the extension! |
- For the
tofield, set the type to array, then add one element of type map with a single keyemail(string) set to the recipient address. - Click Save.
After a few seconds, refresh the document in the Console. You should see a delivery field appear with nested fields like state, startTime, etc.
import { initializeApp } from "firebase/app";
import { getFirestore, collection, addDoc } from "firebase/firestore";
const app = initializeApp({
/* your firebaseConfig object from Project Settings */
});
const db = getFirestore(app);
await addDoc(collection(db, "mail"), {
to: [{ email: "recipient@example.com" }],
subject: "Test email",
text: "Sent from a locally installed extension!",
});- Go to Build > Firestore Database in the Firebase Console.
- Navigate to the
mailcollection and click on a document. - Look at the
deliveryfield:state: "SUCCESS"— email was sent successfullystate: "ERROR"with anerrorfield — something went wrong (check the error message)state: "PROCESSING"— the function is still running
- In the Firebase Console, go to Build > Extensions in the left sidebar.
- Click on the Mailtrap Email extension instance.
- Click the Logs tab to see Cloud Function execution logs including any errors.
Alternatively, view logs via the CLI:
firebase functions:log --only ext-mailtrap-email-processQueueTo see the extension configuration, status, and manage it:
- Go to Build > Extensions in the Firebase Console.
- Here you can see all installed extensions, their status, reconfigure parameters, or uninstall them.
After making changes to the extension source, simply run firebase deploy --only extensions --force again. Firebase will upload and rebuild the updated source.
To remove the extension via CLI:
firebase ext:uninstall mailtrap-email --project=your-firebase-project-idOr via the Console: go to Build > Extensions, click on the extension instance, and click Uninstall extension.
To clean up test data, go to Build > Firestore Database, select the mail collection, click the three-dot menu, and choose Delete collection.
firebase ext:dev:upload mailtrap/mailtrap-email --stage alpha --repo https://github.com/mailtrap/mailtrap-firebase --ref main --root /To upload the extension for the mailtrap publisher (e.g. firebase ext:dev:upload mailtrap/mailtrap-email), use the correct Google account and quota project.
From the project root:
firebase login:listIf the Mailtrap publisher account is not listed, add it (opens browser):
firebase login:addThen set that account as the one to use:
firebase login:use <the Mailtrap account email>The Firebase Extensions Publisher API requires a quota project when using Application Default Credentials.
Create a .env in the project root (already gitignored):
GOOGLE_CLOUD_QUOTA_PROJECT=<the publisher GCP project ID>Use the Google Cloud project ID of the project used for the Firebase Extensions publisher (Mailtrap). Then run the upload with that env loaded:
source .env && firebase ext:dev:upload mailtrap/mailtrap-email