Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Gmail Laravel Package

dacastro4/laravel-gmail

dacastro4/laravel-gmail integrates the Gmail API with Laravel, offering OAuth authentication and a fluent PHP interface to send, read, search, and manage Gmail messages, threads, labels, and attachments without handling raw API requests.

View on GitHub
Deep Wiki
Context7

Getting Started

v7.0 is primarily a framework-compatibility release: it adds Laravel 10/11 support and fixes recipient address handling so addresses can be Address objects or strings. The release notes do not call out breaking API changes, but because this is a major version, treat v7 as the supported baseline for Laravel 10+ and verify your app’s OAuth/token flow after upgrading.

Start here:

  • Read the package README setup and OAuth sections first, then inspect config/gmail.php.
  • Install with composer require dacastro4/laravel-gmail:^7.0.
  • Publish the package config/assets as instructed by the README.
  • Configure Google Cloud: enable the Gmail API, configure the OAuth consent screen, create OAuth credentials, and set the client ID, client secret, redirect URI, and scopes in .env.
  • Complete the OAuth authorization flow for the account you will send/read from, and confirm tokens persist and refresh correctly.
  • First use case: send a test transactional notification through the package facade’s message builder to your own address, then inspect the Gmail API response and sent message.

Implementation Patterns

  • Wrap the package behind an application service such as GmailNotifier or GmailInboxService. Keep facade calls out of controllers so you can test, mock, and swap behavior.
  • Use queued jobs for sending and inbox synchronization. Gmail API calls are network-bound and quota-limited; queueing keeps web requests fast and gives you retries/backoff.
  • Normalize recipient data at your boundary. Since v7 supports both strings and Address objects, accept either in DTOs/form requests and convert to a consistent type before calling the package if your app depends on one shape.
  • For multi-user apps, store and select Gmail tokens per user/account. Do not share a single token across tenants; resolve the correct token before each API call.
  • Use Gmail query syntax for inbox workflows, apply labels for routing/state, and paginate list results rather than fetching large mailboxes synchronously.
  • For attachments, validate size/type before upload, stream from Laravel storage where possible, and avoid loading large attachments fully into memory.
  • Integrate with Laravel notifications/jobs for transactional mail, but do not treat this as a bulk marketing mailer. Gmail API quotas and account sending limits still apply.

Gotchas and Tips

  • Major-version upgrade: update the Composer constraint, run composer update dacastro4/laravel-gmail, clear config cache, and test OAuth, sending, reading, and attachments. If you are below Laravel 10, stay on v6 unless you have verified compatibility.
  • The release history includes a version bump that was reverted. After installing, verify the resolved version with composer show dacastro4/laravel-gmail and pin ^7.0 as needed.
  • OAuth failures are usually configuration issues: exact redirect URI mismatch, missing scopes, unverified consent screen, expired refresh token, or testing with an account not added as a test user.
  • The v7 address fix means your code may now receive/handle Address objects where it previously assumed strings, or vice versa. Add tests for both recipient forms on to, cc, and bcc.
  • Gmail API quotas and rate limits are real. Use exponential backoff, avoid tight retry loops, and log Google’s error payload rather than only the exception message.
  • Sending from aliases requires the alias to be configured in Gmail and authorized for the account. A valid OAuth token does not automatically allow arbitrary From addresses.
  • Attachment and message size limits can surface as opaque API errors. Validate before sending and log the message size and attachment metadata.
  • Treat tokens and service-account credentials as secrets. Encrypt stored tokens where possible, restrict scopes, and never log client secrets or refresh tokens.
  • When debugging, check published config values, cached config, token storage, Google API error responses, and whether re-authorization is required after scope changes.
  • Extension points are best handled through published config and application-level service wrappers. Avoid editing vendor files; if you need custom token storage or transport behavior, check the package provider/config before overriding bindings.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console