0.0.2 • Published 4 years ago

props-lib-email v0.0.2

Weekly downloads
41
License
ISC
Repository
github
Last release
4 years ago

props-lib-email

A simple email sender based on AWS SES.

initialize the lib

import { LibEmailSender } from 'props-lib-email';
await LibEmailSender.init({
      logger: console, // A namespace with a log function x.log(...args)
      aws: {
        region: 'us-east-1',
        ses: {
          accessKeyId: 'KEY',
          secretAccessKey: 'SECRET',
        },
      },
    });

Example of a base template:

export default abstract class EmailTemplateBase {
	protected emailDisclaimer = '<br><br>--------<br><small>Legal Disclaimer: Read more about <a href="https://propsproject.com/">Props here</a>. The Securities and Exchange Commission (SEC) has qualified the offering statement that we have filed with the SEC. The information in that offering statement is more complete than the information we are providing now, and could differ in important ways. You must read the documents filed with the SEC before investing. The offering is being made only by means of its offering statement. This document shall not constitute an offer to sell or the solicitation of an offer to buy, nor shall there be any sale of these securities in any state or jurisdiction in which such offer, solicitation or sale would be unlawful prior to registration or qualification under the securities laws of any such state or jurisdiction. An indication of interest involves no obligation or commitment of any kind. Any person interested in investing in any offering of Props Tokens should review our disclosures and the publicly filed offering statement and the final offering circular that is part of that offering statement at <a href="http://offeringcircular.propsproject.com/">this website</a>. YouNow is not registered, licensed or supervised as a broker dealer or investment adviser by the Securities and Exchange Commission (SEC), the Financial Industry Regulatory Authority (FINRA) or any other financial regulatory authority or licensed to provide any financial advice or services. Forward-looking statements: This communication contains forward-looking statements that are based on our beliefs and assumptions and on information currently available to us. In some cases, you can identify forward-looking statements by the following words: “will,” “expect,” “would,” “intend,” “believe,” or other comparable terminology. Forward-looking statements in this document include, but are not limited to, statements about our plans for developing the platform and future utility for the Props Token, our Reg A+ offering and launch of our network, and collaborations and partnerships. These statements involve risks, uncertainties, assumptions and other factors that may cause actual results or performance to be materially different. More information on the factors, risks and uncertainties that could cause or contribute to such differences is included in our filings with the Securities and Exchange Commission, including in the “Risk Factors” and “Management’s Discussion & Analysis” sections of our offering statement on Form 1-A. We cannot assure you that the forward-looking statements will prove to be accurate. These forward-looking statements speak only as of the date hereof. We disclaim any obligation to update these forward-looking statements.</small>';
	protected body: string;
	protected args: { [key: string]: any };
	constructor(args: { [key: string]: any }) {
		this.args = args;
	}
	getBody(): string {
		return this.parseBody();
	}
	public abstract getSubject(...args): string;
	protected abstract parseBody(): string;

}

Example of a final template:

import BaseEmailTemplate from './base_email_template';
import { LibEmailInterfaces,  LibEmailHTMLComponents } from 'props-lib-email';
const { ButtonComponent, HtmlHeaderComponent } = LibEmailHTMLComponents;

const baseUrl = 'https://propsproject.com'

export default class EmailTemplateExample extends BaseEmailTemplate {
  protected body: string = `
  ${HtmlHeaderComponent.H({
    text: 'Hi, ',
    size: 1,
    backgroundColor: '#64b5f6',
    textColor: '#fff'
  })}
  ${HtmlHeaderComponent.H({
    text: 'How awesome are you?',
    size: 2,
    letterSpacing: 3,
  })}
  <p>Wanna join our awesome team?</p>
  <p>${ButtonComponent.RoundedButton({
    href: `${baseUrl}/careers/%s`, // %s will be replaced by token
    text: 'Join Us!',
    radius: 15,
    backgroundColor: '#64b5f6'
  })}</p><br><br>
  <p>All the best</p>
  Thank you,<br>
  Team Props
  <br><br>
  ${this.emailDisclaimer}
  `;
  protected args: IEmailTemplateArgs;
  constructor(args: IEmailTemplateArgs) {
    super(args);
  }

  protected parseBody(): string {
    const {
      token,
    } = this.args;
    const args = [token];
    var i = 0;
    return this.body.replace(/%s/g, () => args[i++])
  }
  public getSubject(): string {
    return 'Email Template Example'
  }

}
interface IEmailTemplateArgs {
  token: string;
}

Sending the email:

import { LibEmailSender } from 'props-lib-email';
const emailData: LibEmailInterfaces.IEmailData = {
      template: new EmailTemplateExample({token:'random-token-just-to-show-text-replace'}),
      emailAddress: 'support@propsproject.com',
    };
await LibEmailSender.send(emailData); // returns true/false