Introduction to development for notification mail sending with Gmail

Hello,

I’m new to Ruby and Docker, but having some development experience otherwise. I have a running dev Discourse instance as well a production instance, so dependencies seem to be met. I would like to add Oauth 2.0 functionality to no-reply@discourse.example.com, so that I can send the notifications via a Google Workspace user.

I kindly ask your help in the following:

  • how to create the docker image from the discourse git repository?
  • about what part of the code contains the STMP authentication of the no-reply, and sending the notifications?

If it goes well, I would like to make it to be selectable at ./discourse-setup script, so that webmaster can be given in most of the mail providers and OAuth 2.0 when the mail provider is Google. In case you find it useful, I can send the result for review.

Best Regards

You should probably read this from here:

Strongly consider using the standard install

Thank you for your quick response. I would use the ./discourse-setup script, however I need to setup discourse as an OAuth client, not as an SMTP client, so I need to add to the source first. I cannot find the discourse source in the discourse_docker repository. How can I modify the discourse source then run the ./discourse-setup script? If you don’t recommend using ./launcher, I’m okay with not chasing that direction.

Currently, I have discourse and discourse_docker repos.

Would it be something with pulling the local repo to the launcher/discourse-setup script instead of the upstream?

Do you mean SMTP with oAuth authentication instead of Basic authentication? Or are you looking to send mail via some other pathway?

Discourse does not support SMTP oAuth authentication, so the simplest approach is probably having Discourse hand off email to a local mail server configured in such a way that submits the mail with necessary authentication.

Google’s supported mechanism for this seems to be:

1 Like

I mean that in my case Discourse should connect to the mail provider via OAuth 2, and not SMTP. Unfortunately, I found that my mails likely go to spam when not using a big mail provider, so I decided to add OAuth 2 authentication for the no-reply account used by Discourse and connect to Google Workspace. I also tried mailgun, however I would have needed IMAP support too (that for other user accounts not for the no-reply).

I have the time, I can play with it, I just need some help at the start :slight_smile: (And perhaps some more later)

The right way to phrase this is:

I want Discourse to authenticate to the SMTP server using oAuth2 authentication instead of Basic authentication

This is for user replies / inbound mail?

I understand there’s a mailgun plugin for this, though I haven’t used it.

Yes, that’s what I want :slight_smile: I’ve already subscribed to Google Workspace, I would like to push it as far as possible.

Google Workspace isn’t designed for transactional emails. You’ll need to use something else.

If you want to have your forum receive mail, see Configure direct-delivery incoming email for self-hosted sites with Mail-Receiver

Typically, you’d configure some transactional mail service to send from noreply@forum.example.com and the mail receiver would receive mail sent to it and hand it off to discourse.

Thank you so much, I’m trying this now.

1 Like