11import app from '@launchql/knative-job-fn' ;
2+ import { send as sendEmail } from '@launchql/postmaster' ;
23
34type SimpleEmailPayload = {
45 to : string ;
@@ -37,14 +38,29 @@ app.post('*', async (req: any, res: any, next: any) => {
3738 throw new Error ( "Either 'html' or 'text' must be provided" ) ;
3839 }
3940
40- const from = isNonEmptyString ( payload . from ) ? payload . from : undefined ;
41+ const fromEnv = process . env . MAILGUN_FROM ;
42+ const from = isNonEmptyString ( payload . from )
43+ ? payload . from
44+ : isNonEmptyString ( fromEnv )
45+ ? fromEnv
46+ : undefined ;
47+
4148 const replyTo = isNonEmptyString ( payload . replyTo )
4249 ? payload . replyTo
4350 : undefined ;
4451
45- // Log the email (dry-run mode, no actual send)
52+ // Send via @launchql /postmaster (Mailgun or configured provider)
53+ await sendEmail ( {
54+ to,
55+ subject,
56+ ...( html && { html } ) ,
57+ ...( text && { text } ) ,
58+ ...( from && { from } ) ,
59+ ...( replyTo && { replyTo } )
60+ } ) ;
61+
4662 // eslint-disable-next-line no-console
47- console . log ( '[simple-email] DRY RUN email' , {
63+ console . log ( '[simple-email] Sent email' , {
4864 to,
4965 subject,
5066 from,
@@ -53,10 +69,6 @@ app.post('*', async (req: any, res: any, next: any) => {
5369 hasText : Boolean ( text )
5470 } ) ;
5571
56- // Optionally also log the full payload (for debugging)
57- // eslint-disable-next-line no-console
58- console . log ( '[simple-email] DRY RUN payload' , payload ) ;
59-
6072 res . status ( 200 ) . json ( { complete : true } ) ;
6173 } catch ( err ) {
6274 next ( err ) ;
0 commit comments