File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class Mailer extends helper.Mail {
66 constructor ( { subject, recipients } , content ) {
77 super ( ) ;
88
9+ this . sgApi = sendgrid ( keys . sendGridKey ) ;
910 this . from_email = new helper . Email ( 'no-reply@emaily.com' ) ;
1011 this . subject = subject ;
1112 this . body = new helper . Content ( 'text/html' , content ) ;
@@ -29,6 +30,26 @@ class Mailer extends helper.Mail {
2930 trackingSettings . setClickTracking ( clickTracking ) ;
3031 this . addTrackingSettings ( trackingSettings ) ;
3132 }
33+
34+ addRecipients ( ) {
35+ const personalize = new helper . Personalization ( ) ;
36+
37+ this . recipients . forEach ( recipient => {
38+ personalize . addTo ( recipient ) ;
39+ } ) ;
40+ this . addPersonalization ( personalize ) ;
41+ }
42+
43+ async send ( ) {
44+ const request = this . sgApi . emptyRequest ( {
45+ method : 'POST' ,
46+ path : '/v3/mail/send' ,
47+ body : this . toJSON ( )
48+ } ) ;
49+
50+ const response = this . sgApi . API ( request ) ;
51+ return response ;
52+ }
3253}
3354
3455module . exports = Mailer ;
You can’t perform that action at this time.
0 commit comments