What is the most secure method for sending emails programmatically?

Hello,

We are having a bit of a discussion internally on Google’s recommended “Most secure” way to send emails programmatically. We have things like invoices and shipping notifications that we send out to customers and thus we don’t have a user signing in with OAuth. We use C# for coding Windows Forms that run processes and we have a few web services that run things.

I have found that setting up a SMTP Relay for Printers, Devices and Apps says this is the most secure way to send emails when there is no need for user intervention.

My coworker says that OAUTH 2.0 using a Service Account with Domain Wide Delegation is more secure.

We are currently using C#'s SMTP client which requires Username and App Password which we store securely; however, we are looking to move away from storing any credentials locally.

Considering Google doesn’t define this clearly in documentation, I am curious what the experts have to say as I’ve only been working with APIS and stuff for a couple of years.

You could consider assigning an ‘App Password’ to the account, which locks you down to a specific account.

HI @brettfreer Thank you for the suggestion. We are currently using the App Password which is not secure because we have to store it somewhere. I appreciate your suggestion :grinning_face:

If the goal is to securely send emails programmatically from multiple accounts, without storing any credentials, then your co-worker’s recommendation to use DwDg (Domain-Wide Delegation) is probably your best option.

A service account with DwDg enabled can impersonate users in your Google Workspace domain and send out emails on their behalf.

where is the the dev core team for the google workspace developer, i’m having same issue