# Use Google Workspace or Gmail with Custom SMTP

Connect your Google Workspace or Gmail mailbox to PiGi's Custom SMTP integration so your school's customer emails go out from your own address. You need 2-Step Verification and an app password (or a Workspace SMTP relay rule), and Google's daily sending limits apply.

Source: https://help.pigi.io/guides/integrations/communication/gmail-smtp

## Quick answers

**Can PiGi send my customer emails from our Google Workspace or Gmail address?**
Yes. Once Custom SMTP is connected with a working Google login, PiGi sends your school's
customer emails through Google, from the **From Email** you enter. If Google ever refuses
a message, PiGi sends that one from its own no-reply address instead, with your school's
email as the reply address, and shows a warning in the header.

**What are the settings for Google Workspace or Gmail?**
**SMTP Host** `smtp.gmail.com`, **SMTP Port** `465` with **Use SSL/TLS** on, **SMTP
Username** your full email address, **SMTP Password** a 16-character app password. Port
`587` with **Use SSL/TLS** off also works; PiGi then upgrades the connection with
STARTTLS.

**Why does my normal Google password fail?**
Google does not accept your account password from apps like PiGi. You need 2-Step
Verification on the account and an app password created for PiGi.

**Where do I create an app password?**
At myaccount.google.com/apppasswords, after 2-Step Verification is on. Name it "PiGi",
create it, and copy the 16-character code into **SMTP Password**.

**The app password option is missing. Why?**
Google hides it when the account uses security keys only for 2-Step Verification, has
Advanced Protection, or belongs to an organisation that does not allow it. On Google
Workspace, ask your admin to check the 2-Step Verification settings.

**Can emails come from bookings@ourschool.com instead of my own address?**
Yes, if that address is a Workspace alias or group you are allowed to send as, added in
Gmail under **Settings → See all settings → Accounts → Send mail as**. Use your own
mailbox login for **SMTP Username** and the alias in **From Email**.

**How many emails can I send through Gmail?**
A Google Workspace user can send 2,000 messages a day (500 on a trial account). A
personal Gmail account hits a limit above 500 emails a day. Past the limit Google blocks
sending for up to 24 hours, and PiGi falls back to its own no-reply address.

**Does this work on PiGi's test or staging site?**
No. Customer emails go through Google on the live PiGi site only; test and staging sites
always send through PiGi's own service.

**Do Google's sending limits apply to all my customer email?**
Yes. Every customer email your school sends through PiGi counts towards the mailbox's
daily Google limit, not only the ones you send yourself. Once the limit is reached,
PiGi sends the rest from its own no-reply address, with your school's email as the reply
address, until Google lifts the block.

**Should a Google Workspace school use smtp-relay.gmail.com instead?**
Only if your admin sets up an SMTP relay rule that requires SMTP authentication. PiGi
always signs in with a username and password, so a rule that only accepts listed IP
addresses will not work. For most schools, `smtp.gmail.com` with an app password is
simpler.

**What changes if I change my Google password?**
Google revokes all app passwords. Create a new one and paste it into **Update
credentials**, or customer emails fall back to PiGi's no-reply address.

## What this does

Custom SMTP lets PiGi send your booking, invoice and notification emails from your own
mailbox, so replies reach you and customers recognise the sender. Google Workspace is the
most common setup for schools; personal Gmail works the same way with lower limits.
Google charges nothing extra for SMTP; your Workspace subscription or free Gmail account
applies.

## Before you start

- The **admin** role in PiGi.
- The mailbox you will send from, and its password.
- Google Workspace: an admin who can open the Admin console, in case 2-Step Verification
  or app passwords are restricted.

## Set up Google Workspace (admin)

Skip this section for personal Gmail, or if staff can already turn on 2-Step
Verification.

1. In the Admin console, go to **Security → Authentication → 2-step verification**.
2. Tick **Allow users to turn on 2-Step Verification**.
3. Under **Methods**, avoid **Only security key** for the sending mailbox: Google does not
   allow app passwords when security keys are enforced.
4. Optional SMTP relay: go to **Apps → Google Workspace → Gmail → Routing**, find **SMTP
   relay service** and click **Configure**. Choose **Allowed senders**, tick **Require
   SMTP Authentication** and **Require TLS encryption**, and save. In PiGi, use **SMTP
   Host** `smtp-relay.gmail.com`, port `587`, **Use SSL/TLS** off, and the mailbox
   address and app password.

## Set up the mailbox

1. Sign in to the sending mailbox and open your Google Account.
2. Open **Security & sign-in** and, under "How you sign in to Google", turn on **2-Step
   Verification**. Follow the steps.
3. Go to myaccount.google.com/apppasswords. Enter a name such as "PiGi" and create the
   password.
4. Copy the 16-character code. Google shows it once.
5. For a shared address such as bookings@: in Gmail, open **Settings → See all settings →
   Accounts** (or **Accounts and Import**), and under **Send mail as** click **Add another
   email address**, then confirm the verification email.

## Connect it to PiGi

1. Open **Settings → Communication → Integrations**, click **Custom SMTP**, then
   **Connect Custom SMTP**.
2. Click **Add credentials** and fill in:
   - **SMTP Host**: `smtp.gmail.com`
   - **SMTP Port**: `465`, with **Use SSL/TLS** on (or `587` with it off)
   - **SMTP Username**: the full mailbox address, such as person@examplecompany.com
   - **SMTP Password**: the app password
   - **From Email**: the mailbox address or a **Send mail as** address
   - **From Name**: your school's name, if wanted
   - **Reply-To Email (optional)**: where replies go, if not the From address
3. Click **Save**.

## Test it

1. Click **Test connection**. "Connected to smtp.gmail.com:465 and authenticated." means
   Google accepted the login.
2. Click **Send a test email**, enter an address in **Send to** and click **Send**.
   Check that inbox, including spam.

## Troubleshooting

| Message | What to do |
|---|---|
| "Auth failed: 534 …" | Google wants an app password. Turn on 2-Step Verification and create one. |
| "Auth failed: 535 …" | Wrong username or app password. Use the full address and a fresh app password, without spaces. |
| "SMTP error: …" | Check the host, and that **Use SSL/TLS** is on for 465 and off for 587. |
| "Need host, username, and password to test." | Fill in the missing fields under **Update credentials**. |
| "The server refused the recipient: …" | Google would not send to that address; check it, or your sending limit. |

## Known limitations

- **Live site only.** Customer emails go through Google on the live PiGi site; PiGi's
  test and staging sites never use your mailbox.
- **A refused email falls back.** If Google refuses a message, the customer gets it
  from PiGi's no-reply address instead, with your school's email as the reply address,
  and a Custom SMTP warning appears in the header.
- **Google's daily limits apply to all your customer email.** Every booking, invoice and
  notification email counts. A busy day can use up a personal Gmail account's limit,
  and the rest go out from PiGi's no-reply address.

## Sources

- [Google Account Help: Sign in with app passwords](https://support.google.com/accounts/answer/185833)
- [Google Account Help: Turn on 2-Step Verification](https://support.google.com/accounts/answer/185839)
- [Google Workspace Admin Help: Send email from a printer, scanner, or app](https://knowledge.workspace.google.com/admin/gmail/send-email-from-a-printer-scanner-or-app)
- [Google Workspace Admin Help: Route outgoing SMTP relay messages through Google](https://knowledge.workspace.google.com/admin/gmail/advanced/route-outgoing-smtp-relay-messages-through-google)
- [Google Workspace Admin Help: Deploy 2-Step Verification](https://knowledge.workspace.google.com/admin/security/deploy-2-step-verification)
- [Google Workspace Admin Help: How 2-Step Verification works with legacy apps](https://knowledge.workspace.google.com/admin/security/how-2-step-verification-works-with-legacy-apps)
- [Google Workspace Admin Help: Gmail sending limits in Google Workspace](https://knowledge.workspace.google.com/admin/gmail/gmail-sending-limits-in-google-workspace)
- [Gmail Help: You have reached a limit for sending mail](https://support.google.com/mail/answer/22839)
- [Gmail Help: Send emails from a different address or alias](https://support.google.com/mail/answer/22370)
- [Gmail Help: Read Gmail messages on other email clients using POP (SMTP settings)](https://support.google.com/mail/answer/7104828)
