import { injectable } from 'inversify' ; import * as sgMail from '@sendgrid/mail' ; import { SecretsConfig } from '@centsideas/config' ; import { MailingConfig } from './mailing.config' ; @ injectable ( ) export class EmailService { private readonly from = this . config . get ( 'mailing.from' ) ; constructor ( private secretsConfig , private config ) { sgMail . setApiKey ( this . secretsConfig . get ( 'secrets.sendgrid.api' ) ) ; } sendMail ( to , { subject , text , html } ) { const message = { to , from : this . from , subject , text , html } ; return sgMail . send ( message ) ; } }