Koha Solutions

Configuration & operations

Using a Gmail account as Koha’s SMTP server

Gmail works as Koha’s mail server, but only with an app password and two-step verification on. Here are the exact settings, and the limits worth knowing before you rely on it.

Updated 2026-08-09 · Tested against Koha 26.05

Gmail works as Koha's SMTP server: host smtp.gmail.com, port 587, SSL mode STARTTLS, the full address as the user name, and a 16-character app password — not the account password. App passwords require two-step verification on the account first; there is no way around that any more.

Suitable for a small library, not a large one

A consumer Gmail account is rate-limited to a few hundred recipients a day, and Google will pause an account that trips it. A library sending overdue notices to a few thousand patrons will hit it in one nightly run.
  • Under a few hundred notices a day: Gmail is fine and free.
  • More than that: use a transactional mail provider, or your institution's own mail server.

Whichever you pick, the Koha side is identical — only the host, port and credentials change.

Step 1Create the app password

Google removed the "less secure app access" switch, so an ordinary password will be refused no matter how correct the rest of the configuration is. An app password is a per-application credential you generate once and paste into Koha.

  1. 1Sign in as the account that will send the notices — ideally a dedicated mailbox such as library-notices@…, not a person's.
  2. 2Turn on 2-Step Verification in the account's security settings. App passwords are not offered until you do.
  3. 3Open the App passwords page for that account.
  4. 4Name it Koha so you can revoke it later without guessing.
  5. 5Copy the 16-character password it shows. It is displayed once.

Google Workspace administrators

If the App passwords page is missing on a Workspace account, an administrator has disabled it for the organisation. It is re-enabled per organisational unit in the Admin console — or use the Workspace SMTP relay service instead, which authenticates by IP and needs no password at all.

Step 2Enter it in Koha

Go to Administration → Additional parameters → SMTP servers and either add a server or edit the one you have.

FieldValue
Hostsmtp.gmail.com
Port587
SSL modeSTARTTLS
User nameThe full address, e.g. library-notices@example.org
PasswordThe 16-character app password, with no spaces
DefaultTicked, unless you are testing a second server

Google displays the app password in four groups of four. Paste it without the spaces. Port 465 with SSL mode SSL also works if 587 is blocked outbound on your network; do not mix the two.

Step 3Make the from-address match

Gmail will not send as an address it does not own. If your library email in Administration → Libraries is info@yourlibrary.org but the SMTP account is a @gmail.com address, Google rewrites the sender or rejects the message outright — and patrons reply into a mailbox nobody reads.

  • Simplest: make the library email address and KohaAdminEmailAddress the same address as the SMTP account.
  • On Workspace with your own domain, that is already true and nothing further is needed.
  • On consumer Gmail with a different reply-to domain, add the address in Gmail under Send mail as and verify it first.

Step 4Test it before you trust it

Enable email for the instance if you have not already, then run the delivery job by hand and watch it:

Terminal
sudo koha-email-enable librarysudo koha-foreach --chdir --enabled --email \    /usr/share/koha/bin/cronjobs/process_message_queue.pl -v

Nothing to send? Trigger a notice first — a patron password reset is the quickest. If messages sit in the queue rather than failing, the problem is the instance flag, not Gmail; the full sequence is in configuring SMTP in Koha.

Why an app password and not the real one

A password typed into a login form is protected by everything around it — the second factor, the device check, the sign-in alert. A password stored in a server's database has none of that, and Koha needs to present it unattended every 15 minutes. Google's position is that a credential used that way should be a different credential: scoped to one application, revocable on its own, and useless for signing in to the account.

That is worth taking seriously rather than working around. The app password lives in your Koha database, and anyone with database access can read it — so use a mailbox that sends notices and does nothing else, and revoke the credential rather than change the account password when someone leaves.

Common failures

What you seeWhat it usually is
<code>Username and Password not accepted</code>The account password was used instead of an app password, or the app password was pasted with its spaces.
App passwords option missingTwo-step verification is off, or a Workspace administrator has disabled app passwords for the organisation.
Connection times outOutbound port 587 is blocked by a firewall. Try 465 with SSL mode SSL, or open the port.
Sends for a week, then stopsThe daily sending limit was reached. Notices resume the next day and the queue is not lost, but this is the signal to move off Gmail.
Arrives in spamThe from-address domain has no SPF record naming Google as a sender. Fix it at your DNS host.

Share this article

Would rather not do this yourself? We do it as a service — and if you would rather it were already done, it is on Koha Cloud before you log in.