diff --git a/backend/src/services/smtp.ts b/backend/src/services/smtp.ts index 6bae626be..e7c55dfff 100644 --- a/backend/src/services/smtp.ts +++ b/backend/src/services/smtp.ts @@ -3,7 +3,8 @@ import { SMTP_HOST_SENDGRID, SMTP_HOST_MAILGUN, SMTP_HOST_SOCKETLABS, - SMTP_HOST_ZOHOMAIL + SMTP_HOST_ZOHOMAIL, + SMTP_HOST_GMAIL } from '../variables'; import SMTPConnection from 'nodemailer/lib/smtp-connection'; import * as Sentry from '@sentry/node'; @@ -46,6 +47,12 @@ export const initSmtp = async () => { } break; case SMTP_HOST_ZOHOMAIL: + mailOpts.requireTLS = true; + mailOpts.tls = { + ciphers: 'TLSv1.2' + } + break; + case SMTP_HOST_GMAIL: mailOpts.requireTLS = true; mailOpts.tls = { ciphers: 'TLSv1.2' diff --git a/backend/src/variables/index.ts b/backend/src/variables/index.ts index 979de21ab..450c2fedd 100644 --- a/backend/src/variables/index.ts +++ b/backend/src/variables/index.ts @@ -55,7 +55,8 @@ import { SMTP_HOST_SENDGRID, SMTP_HOST_MAILGUN, SMTP_HOST_SOCKETLABS, - SMTP_HOST_ZOHOMAIL + SMTP_HOST_ZOHOMAIL, + SMTP_HOST_GMAIL } from './smtp'; import { PLAN_STARTER, PLAN_PRO } from './stripe'; import { @@ -138,6 +139,7 @@ export { SMTP_HOST_MAILGUN, SMTP_HOST_SOCKETLABS, SMTP_HOST_ZOHOMAIL, + SMTP_HOST_GMAIL, PLAN_STARTER, PLAN_PRO, MFA_METHOD_EMAIL, diff --git a/backend/src/variables/smtp.ts b/backend/src/variables/smtp.ts index a88f229bd..3ec46c4e7 100644 --- a/backend/src/variables/smtp.ts +++ b/backend/src/variables/smtp.ts @@ -2,10 +2,12 @@ const SMTP_HOST_SENDGRID = 'smtp.sendgrid.net'; const SMTP_HOST_MAILGUN = 'smtp.mailgun.org'; const SMTP_HOST_SOCKETLABS = 'smtp.socketlabs.com'; const SMTP_HOST_ZOHOMAIL = 'smtp.zoho.com'; +const SMTP_HOST_GMAIL = 'smtp.gmail.com'; export { SMTP_HOST_SENDGRID, SMTP_HOST_MAILGUN, SMTP_HOST_SOCKETLABS, - SMTP_HOST_ZOHOMAIL + SMTP_HOST_ZOHOMAIL, + SMTP_HOST_GMAIL } \ No newline at end of file diff --git a/docs/images/email-gmail-app-access.png b/docs/images/email-gmail-app-access.png new file mode 100644 index 000000000..43f0b63a4 Binary files /dev/null and b/docs/images/email-gmail-app-access.png differ diff --git a/docs/self-hosting/configuration/email.mdx b/docs/self-hosting/configuration/email.mdx index a6b13fa0b..ce841db55 100644 --- a/docs/self-hosting/configuration/email.mdx +++ b/docs/self-hosting/configuration/email.mdx @@ -23,7 +23,7 @@ By default, you need to configure the following SMTP [environment variables](htt - `SMTP_FROM_ADDRESS`: Email address to be used for sending emails (e.g. team@infisical.com). - `SMTP_FROM_NAME`: Name label to be used in `From` field (e.g. Team). -Below you will find details on how to configure common email providers (not in any particular order). +Below you will find details on how to configure common email providers: @@ -135,6 +135,34 @@ SMTP_FROM_NAME=Infisical + + +Create an account and enable "less secure app access" in Gmail Account Settings > Security. This will allow +applications like Infisical to authenticate with Gmail via your username and password. + +![Gmail secure app access](../../images/email-gmail-app-access.png) + +With your Gmail username and password, you can set your SMTP environment variables: + +``` +SMTP_HOST=smtp.gmail.com +SMTP_USERNAME=hey@gmail.com # your email +SMTP_PASSWORD=password # your password +SMTP_PORT=587 +SMTP_SECURE=true +SMTP_FROM_ADDRESS=hey@gmail.com +SMTP_FROM_NAME=Infisical +``` + + + As per the [notice](https://support.google.com/accounts/answer/6010255?hl=en) by Google, you should note that using Gmail credentials for SMTP configuration + will only work for Google Workspace or Google Cloud Identity customers as of May 30, 2022. + + Put differently, the SMTP configuration is only possible with business (not personal) Gmail credentials. + + + + 1. Create an account and configure [Zoho Mail](https://www.zoho.com/mail/) to send emails.