Email/SMTP Configuration

monetr supports sending email notifications (and email verification) if SMTP is configured. Currently emails can be sent when a user creates a new account, forgets their password, or changes their password.

All email features require that enabled is set to true and a valid smtp config is provided. monetr does not support specific email APIs and has no plans to. Several email providers offer an SMTP relay, this is monetr's preferred method of sending emails as it is the most flexible.

Below is an example of the email/SMTP configuration block:

config.yaml
email:
  enabled: true
  domain: "example.com"
  blockedDomains: [ ... ] # Email domains not allowed to sign up (sign up only)
  verification: { ... }   # Email verification configuration
  forgotPassword: { ... } # Password reset via email link
  smtp: { ... }           # SMTP configuration
NameTypeDefaultDescription
enabledBooleanfalseAre email notifications enabled on this server?
domainStringEmail domain used to send emails, emails will always be sent from no-reply@{DOMAIN}. Do not provide a full URL with a protocol.
blockedDomainsListEmail domains that are not allowed to sign up for a new account. Only affects sign up, not sign in. See Blocked Sign Up Domains.

The following environment variables map to the following configuration file fields. Each field is documented below.

VariableConfig File Field
MONETR_EMAIL_ENABLEDemail.enabled
MONETR_EMAIL_DOMAINemail.domain
MONETR_EMAIL_BLOCKED_DOMAINSemail.blockedDomains

Blocked Sign Up Domains

If you want to keep certain email domains (such as disposable or throwaway email providers) from being used to create new accounts, add them to blockedDomains. This only restricts sign up, an account that already exists on one of these domains can still sign in, reset its password, and verify its email. It works regardless of whether email sending is enabled, it does not require SMTP to be configured.

The match is case insensitive and matches the domain exactly, so blocking example.com does not block mail.example.com. An empty list (the default) disables the feature.

When someone tries to sign up with a blocked domain monetr intentionally returns the same "email already in use" error that it returns for an address that is already registered. This is so the blocklist is not disclosed to people signing up. The actual reason, including which domain was blocked, is recorded in the server logs.

config.yaml
email:
  blockedDomains:
    - mailinator.com
    - guerrillamail.com

When set via the environment variable the domains are comma separated, for example MONETR_EMAIL_BLOCKED_DOMAINS=mailinator.com,guerrillamail.com.

Email Verification Configuration

If you want to require users to verify their email address when they create a new login on monetr, you can enable email verification. This will email users a link that they must click after creating their login, the link's lifetime can be customized if needed.

An example of the email verification config:

config.yaml
email:
  verification:
    enabled: true      # Can be true or false
    tokenLifetime: 10m # Duration that the verification link should be valid

The token lifetime is parsed using time.ParseDuration(...), any value that can be parsed using that function is a valid configuration value.

NameTypeDefaultDescription
enabledBooleanfalseIs email verification enabled/required on this server?
tokenLifetimeDuration10mHow long should the link in the verification email be valid?

The following environment variables map to the following configuration file fields. Each field is documented below.

VariableConfig File Field
MONETR_EMAIL_VERIFICATION_ENABLEDemail.verification.enabled
MONETR_EMAIL_VERIFICATION_TOKEN_LIFETIMEemail.verification.tokenLifetime

Forgot Password Configuration

If you ever lose your password and need to reset it, the easiest way is by using the forgot password form. This will send an email to the user (if a user with that email exists) that includes a link to reset their password. Similar to the Email Verification Configuration, this also only requires an enabled and tokenLifetime value.

Example of the forgot password configuration:

config.yaml
email:
  forgotPassword:
    enabled: true      # Can be true or false
    tokenLifetime: 10m # Duration that the password reset link should be valid
NameTypeDefaultDescription
enabledBooleanfalseAre users allowed to reset their password via forgot password?
tokenLifetimeDuration10mHow long should the password reset link be valid?

The following environment variables map to the following configuration file fields. Each field is documented below.

VariableConfig File Field
MONETR_EMAIL_FORGOT_PASSWORD_ENABLEDemail.forgotPassword.enabled
MONETR_EMAIL_FORGOT_PASSWORD_TOKEN_LIFETIMEemail.forgotPassword.tokenLifetime

SMTP Configuration

Make sure to read the documentation for your email provider. monetr requires TLS support from the SMTP server that it is connecting to. This can be via STARTTLS or via a dedicated TLS port on the server. Consult your providers documentation for specifics.

Info

monetr's SMTP implementation requires TLS. Your email provider must support TLS on whatever port specified below.

config.yaml
email:
  smtp:
    username: "..." # SMTP Username
    password: "..." # SMTP Password or app password depending on provider
    host: "..."     # Domain name of the SMTP server, no protocol or port specified
    port: 587       # Use the port specified by your provider, could be 587, 465 or 25
NameTypeDefaultDescription
usernameStringThe username provided by your SMTP provider or relay.
passwordStringThe password provided by your SMTP provider or relay, this may also be an API credential or an "app password" depending on your provider.
hostStringThe hostname or IP address of the SMTP server you are sending email with.
portStringThe port specified by your provider to use, typical ports are 587, 465 or 25.

The following environment variables map to the following configuration file fields. Each field is documented below.

VariableConfig File Field
MONETR_EMAIL_SMTP_USERNAMEemail.smtp.username
MONETR_EMAIL_SMTP_PASSWORDemail.smtp.password
MONETR_EMAIL_SMTP_HOSTemail.smtp.host
MONETR_EMAIL_SMTP_PORTemail.smtp.port