@@ -34,6 +34,7 @@ import localGlobalOperations from './globals/operations/local';
3434import { encrypt , decrypt } from './auth/crypto' ;
3535import { MockEmailHandler , BuildEmailResult , Message } from './email/types' ;
3636import { PayloadRequest } from './express/types' ;
37+ import sendEmail from './email/sendEmail' ;
3738
3839import { Options as CreateOptions } from './collections/operations/local/create' ;
3940import { Options as FindOptions } from './collections/operations/local/find' ;
@@ -67,6 +68,8 @@ export class Payload {
6768
6869 email : BuildEmailResult ;
6970
71+ sendEmail : ( message : Message ) => Promise < unknown > ;
72+
7073 license : string ;
7174
7275 secret : string ;
@@ -133,6 +136,7 @@ export class Payload {
133136
134137 // Configure email service
135138 this . email = buildEmail ( this . emailOptions ) ;
139+ this . sendEmail = sendEmail . bind ( this ) ;
136140
137141 // Initialize collections & globals
138142 initCollections ( this ) ;
@@ -184,17 +188,6 @@ export class Payload {
184188 if ( typeof options . onInit === 'function' ) options . onInit ( this ) ;
185189 }
186190
187- sendEmail = async ( message : Message ) : Promise < unknown > => {
188- const email = await this . email ;
189- const result = email . transport . sendMail ( message ) ;
190- return result ;
191- }
192-
193- getMockEmailCredentials = async ( ) : Promise < TestAccount > => {
194- const email = await this . email as MockEmailHandler ;
195- return email . account ;
196- }
197-
198191 getAdminURL = ( ) : string => `${ this . config . serverURL } ${ this . config . routes . admin } ` ;
199192
200193 getAPIURL = ( ) : string => `${ this . config . serverURL } ${ this . config . routes . api } ` ;
0 commit comments