Skip to content

Email Service

Add an option to create mail on the site with admin login, not hardcoded like these

This is the same service as in the node-server-starter, updates should be in both.

!!!

This should only focus on sending the emails, no routes or handlers. Try to make it as dumb as possible.

This service shouldn’t be crafting the emails, such as sendResetPasswordEmail. Instead, users of the service should pass the contents to the service. That way the auth service can make it’s own content for the email service to stick in a template and send.

emailService/index exports

const EmailService = {
sendResetPasswordEmail,
sendVerificationEmail,
sendContactEmail,
}
  • .env

    transport varibles

    # Email
    SMTP_HOST=mail.elliotreed.net
    SMTP_PORT=465
    SMTP_USERNAME=server@elliotreed.net
    SMTP_PASSWORD=s-3R-v3r.n3t
    EMAIL_FROM=server@elliotreed.net
    EMAIL_RECEIVER=test@elliotreed.dev
    EMAIL_TOKEN_EXPIRATION=3600000
  • config/email.config

    ? empty

  • config/template.config

    returns a config object for email properties

    this would be better with a database adapter so defaults could be changed from the app. with a fallback to default hard-coded values.