This package provides a simple interface to send emails for HacKSU and Kent Hack Enough.
Supports email templates, React JSX, markdown, Sass, and more.
import{Email,EmailTemplate,Stylesheet,Sendgrid,SUBSTITUTION_TAG}from'@hacksu/email';// used to deliver Email objects as actual mailconstSendgridDelivery=newSendgrid('SENDGRID_API_KEY',{// sendgrid mail parameters// these will get applied to each email sent through this instancefrom: 'mail@hacksu.com',})// Including stylesheets in react emailsconstHacksuMailingStyles=Stylesheet('@email/welcome.scss')// @email/... refers to @hacksu/email/src/styles/...// You can also pass in relative paths that will be relative to current script// Stylesheets can also be merged together and stringifiedconstSomeStyles=Stylesheet(Stylesheet('./style.scss')+HacksuMailingStyles);// deliver a markdown emailSendgridDelivery.send(newEmail({from: "mail@hacksu.com',
to: 'test@example.com',subject: "hi there!",content: `# Title 1## Title 2Content<a href="%unsubscribe%">unsubscribe</a> `}))// react JSX email template// substitution tags are %field%, or SUBSTITUTION_TAG(field)constWelcomeTemplate=EmailTemplate({subject: "Welcome to HacKSU!",content: (<div><HacksuMailingStyles/><h1>Hey %name%! %subject</h1><ahref={SUBSTITUTION_TAG('unsubscribe')}>
unsubscribe from our emails
</a></div>)})// deliver the emailSendgridDelivery.send(newWelcomeTemplate({to: 'joe@example.com',name: 'Joe',}),{// sendgrid fields (such as from, to, subject)// can also be applied here rather than directly// on the email instance itself})