Git Product home page Git Product logo

wn-gmaildriver-plugin's Introduction

Gmail Mailer Driver

GitHub Packagist PHP Version Support GitHub tag (latest by date) Packagist Version

Send email with Gmail using this driver plugin for Winter CMS.

Note: You must use version 1.0.15 with Winter CMS < v1.2.

Note: You must use at least version 1.1.0 with Winter CMS >= v1.2. This version of Winter has introduced changes to the way mail transports are configured (See Installing for more info).

Installing

composer require zaxbux/wn-gmaildriver-plugin

In your Winter CMS config/mail.php, add the gmail transport to the mailers array:

'mailers' => [

	// ...

	'gmail' => [
		'transport' => 'gmail',
	],

	// ...
],

Requirements

  • A Gmail account. Google Workspace (G Suite) accounts are also supported, if your administrator has enabled access.
  • Gmail API credentials (see below).

Plugin Settings

The plugin is configured in your backend settings. Change the mail method to Gmail in Mail configuration and configure your API credentials. Obtain API credentials from the Google Cloud Console.

Obtaining API Keys

Read instructions on obtaining API keys

Testing delivery

To make sure everything is working, try test sending a mail template to yourself.

Revoking access

In case you want to revoke access, click the Revoke Authorization or Reset to default buttons on the Gmail configuration page. This will delete the credentials and access tokens. You may also want to remove app access on your Google account.

Important Notes

  • The Gmail API will only send emails as the account which you granted access with, it is currently not possible to send email as another user.
  • The Gmail API has sending limits for free (consumer) and paid (Workspace) accounts.
  • You can send email using another email address under your control, using an alias. Learn more about configuring sending aliases in this Google Support article. Change the Sender email in Mail configuration to match your alias. The Sender Name does not have to match and can be whatever you choose.
  • The authorization tokens expire if not used for 6 months or if you change your Google account password.

Advanced Usage

This section is for advanced users.

Providing credentials

To provide the OAuth credentials without entering them through the backend UI, you can add them in the config/mail.php file. This is useful if you want to provide credentials using an environment variable. By default, the contents of the GOOGLE_APPLICATION_CREDENTIALS_JSON environment variable will be used.

Example:

'mailers' => [
	'gmail' => [
		'transport' => 'gmail',
		// ...

		'client_id' => '...',      // Your OAuth client ID
		'client_secret' => '...',  // Your OAuth client secret

		// ...
	],
],

Authentication Scopes

To change the authentication scopes (permissions requested from the user), you can override the default scopes in the config/mail.php file. Add scopes to the mail/mailers.gmail.scopes array. For the plugin to function correctly, the gmail.send scope is required (this scope is always included by the plugin). Gmail Auth Scopes

Example:

'mailers' => [

	// ...

	'gmail' => [
		'transport' => 'gmail',
		
		// ...

		'scopes' => [
			\Google_Service_Gmail::GMAIL_READONLY,
		],
	],

	// ...
],

Change Log

  • 1.1.0 - Support for Winter CMS 1.2, Laravel 9, and PHP 8.
  • 1.0.16 - Fixed localization key issue and updated dependencies.
  • 1.0.15 - Fixed migration to Winter (@mjauvin)
  • 1.0.14 - Removed requirement to upload JSON file, client secret is now encrypted in DB.
  • 1.0.13 - Added Gmail alias documentation, added ability to pass credentials via environment vars.
  • 1.0.12 - Improve UI.
  • 1.0.11 - Increased max sending size to 35MB (encoded message size).
  • 1.0.10 - Added ability to change auth scopes used with the Google API client.
  • 1.0.9 - Improved localization.
  • 1.0.8 - Plugin requires elevated permissions to function on restore password page.
  • 1.0.7 - Added settings permissions
  • 1.0.6 - Added authorization status dashboard widget.
  • 1.0.5 - Cleaned up Gmail API authorization flow.
  • 1.0.4 - Fixed issue where backend authorization status showed expired when it was authorized.
  • 1.0.3 - Fixed logic issues, app is removed from user account when settings are reset. Updated dependencies.
  • 1.0.2 - Fixed errors that occur when invalid credentials are supplied.
  • 1.0.1 - First version.

Acknowledgments

  • @alxy - Increased max sending size to 35MB.

wn-gmaildriver-plugin's People

Contributors

alxy avatar dependabot[bot] avatar mjauvin avatar zaxbux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wn-gmaildriver-plugin's Issues

Can't authorize plugin app

Hi,

i'm trying to use your plugin on latest Winter release 1.1.7
I followed the api credenztials instruction, installed the plugin and cofigured it.

image

If i click on the authorize button nothing happens.

If i go to redirect URI i encounter this problem:
image

Please can you help me?

Thanks!

I think this plugin is very usefull. I wanted also to crfeate something like this.
Have you ever thinked about using gmail as mail sander also for mailing list? Extendind this plugin also to send mass mail.
Gmail can send 2000 mail per day from api, if i remember well!

Quick question about benefits

Thanks for this plugin - just got it set up.

I was wondering what the benefit was to using this over normal SMTP. Am I right in thinking that I still need to "allow less secure apps" on the mailing account for this to work?

Is it working?

I noticed the plugin has been removed from the OctoberCMS plugin marketplace, any specific reason?
Can we still use this plugin version for production?

Support for Winter 1.2 (Laravel 9)?

Hello,

I've been using your plugin to send emails from my winter cms but since upgrading to Winter 1.2, which uses Laravel 9, this plugin has stopped working.

I've asked Winter for support who ask me to contact you.

The error I am getting is:

Expected response code "250/251/252" but got code "550", with message "550 5.7.1 Relaying denied".

Any support would be really apreciated.

Thank you.

Make scopes a config option

Hi, thanks for this awesome plugin.

Can you make the scopes a (file-based) configuration option? I want to use your plugin not only to send mails, but also to read and delete mails and dont want to bother with the authentication stuff, that is really very nicely integrated here already :)

Unhandled errors when invalid credentials are uploaded

Thanks for this plugin! Unfortunately I ran into three issues.

Issue 1

When going through your steps, at first I skipped step 6 and 7

  1. Copy the Authorized Redirect URI from the backend Gmail configuration page.
  2. Add that URI as an Authorized redirect URI and click Create
    Since I figured I can configure restrictions later.

After completing step 10

  1. Upload the file you downloaded to the backend Gmail configuration page and save the settings. Reload the page to show the Authorize button.
    I got the following bug, and could no longer access the plugin configuration screen:
    "Undefined index: expires_in" on line 470 of /var/www/lineahotels.hu/public_html/plugins/zaxbux/gmailmailerdriver/vendor/google/apiclient/src/Google/Client.php

Note that it is also possible to get here if the user forgets to hit "enter" after entering the redirect URI on google's pages, which is an easy mistake to make, because google doesn't warn the user that the URI wasn't actually added/saved.

Issue 2

So I figured I'll delete the uploaded JSON credential file, which I did (somewhere under /storage/app/uploads/protected/...) as well as the corresponding file from the system_files table.

At this point I was able to again access the plugin config page. I completed steps 6 and 7 above which I skipped previously, and re-uploaded the JSON file.

Now, I got this error:
"Undefined index: expires_in" on line 470 of /var/www/lineahotels.hu/public_html/plugins/zaxbux/gmailmailerdriver/vendor/google/apiclient/src/Google/Client.php

Issue 3

So I figured OK, I'll delete the plugin and re-add it. So I did so and went through all of the steps and got to step 11:

  1. Click the Authorize button to open the Google consent page. Continue to select the account you want to send email with and consent to sending email on your behalf.

After authorizing the plugin through the google dialogs, when it returned to OctoberCMS I got this error:

Object of class Illuminate\Support\Facades\Response could not be converted to string
/var/www/lineahotels.hu/public_html/vendor/october/rain/src/Html/BlockBuilder.php line 80

I'm attaching the full error page:
Exception.zip

So now I'm stuck.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.