Security policy is requiring us to update passwords regularly, and this includes service accounts previously in use for services such as SMTP from our web servers. We are looking to use the Gmail API (Google is the company email provider) to authorize sending emails from the Sitecore web servers for basic email communications with CMS users and admins (password resets, etc.). We understand the Gmail side of things well enough and can create an app and credentials, as outlined here: https://developers.google.com/gmail/api/auth/web-server

However, I do not see any way to do this natively in Sitecore without a custom extension of some kind. Google provides a doc on a custom .NET app to send email, but this is not Sitecore specific. https://developers.google.com/gmail/api/quickstart/dotnet

How could this be done in a manageable way or is there a reliable code resource? I have searched, but find zero.

  • Clarification question: When you say sending emails, are you meaning sending just service emails through the .NET provided SMTP provider? Or through something like EXM or Sitecore Send? Jul 27, 2022 at 15:35
  • A Security Policy to change service account passwords regularly sounds like a production nightmare. I'm sure your company will regret that decision. Jul 27, 2022 at 15:48
  • Just service emails through the .NET provided SMTP provider. Not marketing related.
    – sturtus
    Jul 27, 2022 at 20:32

2 Answers 2


At it's core, Sitecore is a .NET app, it uses the generic ASP.NET SMTP configuration that's generally setup via the Web.config for simple SMTP.

So, if Google has a solve for a custom .NET app, it should still work.

Sitecore doesn't utilize SMTP much except for the Password email.

If you are creating a custom service message in Sitecore, I am assuming you are using the standard .NET classes for sending mail which is the SmtpClient class found in the System.Net.Mail namespace.

If you are using the simplistic MainUtil.SendMail() method from Sitecore this is simply just a Wrapper method for the .NET SmtpClient.

So, using the Google provided solve for a custom .NET class should work.


If I were tasked with this I would first consider how this capability could be shared across applications. Perhaps this isn't something specifically solving an issue with the Sitecore CMS users, but a general concern among applications/teams at your organization.

I would build a mail service on a modern version of .Net where newer resources are available. Take for example this article; the author builds on .Net 5 (at this point you should use 6 because of LTS) using Mailkit. Toss in some scheduler/background service action like with Quartz.NET and now you are really taking advantage of all the goodies that come with .Net and the open source community.

If this custom service you build exposes an API then you could post notifications to the service (maybe stored in a database) and then let the service do its thing. Then you could call this new API with SPE or from any of the custom code you've written for Sitecore.

Finally, the challenge of changing a password frequently could disrupt the availability of Sitecore for your users. Shifting the concern to an external service could reduce the downtime and perhaps be an event users don't even notice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.