File tree Expand file tree Collapse file tree 2 files changed +25
-24
lines changed Expand file tree Collapse file tree 2 files changed +25
-24
lines changed Original file line number Diff line number Diff line change 1+ import nodemailer from 'nodemailer' ;
2+
3+ const {
4+ SMTP_HOST ,
5+ SMTP_PORT ,
6+ SMTP_USERNAME ,
7+ SMTP_PASSWORD
8+ } = process . env ;
9+
10+ if ( ! SMTP_HOST ) throw new Error ( 'No SMTP host configured' ) ;
11+ if ( ! SMTP_PORT ) throw new Error ( 'No SMTP port configured' ) ;
12+ if ( ! SMTP_USERNAME ) throw new Error ( 'No SMTP user configured' ) ;
13+ if ( ! SMTP_PASSWORD ) throw new Error ( 'No SMTP password configured' ) ;
14+
15+ export const mailer = nodemailer . createTransport ( {
16+ host : SMTP_HOST ,
17+ port : Number ( SMTP_PORT ) ,
18+ secure : true ,
19+ auth : {
20+ user : SMTP_USERNAME ,
21+ pass : SMTP_PASSWORD
22+ }
23+ } ) ;
Original file line number Diff line number Diff line change 11import * as _ from 'lodash' ;
2- import nodemailer from 'nodemailer' ;
32import * as log from 'loglevel' ;
43import { delay } from '@httptoolkit/util' ;
54
65import { catchErrors , reportError } from '../errors' ;
76import { getCorsResponseHeaders } from '../cors' ;
7+ import { mailer } from '../email' ;
88
9- const {
10- CONTACT_FORM_DESTINATION ,
11- SMTP_HOST ,
12- SMTP_PORT ,
13- SMTP_USERNAME ,
14- SMTP_PASSWORD
15- } = process . env ;
16-
9+ const { CONTACT_FORM_DESTINATION } = process . env ;
1710if ( ! CONTACT_FORM_DESTINATION ) throw new Error ( 'No contact form destination configured' ) ;
1811
19- if ( ! SMTP_HOST ) throw new Error ( 'No SMTP host configured' ) ;
20- if ( ! SMTP_PORT ) throw new Error ( 'No SMTP port configured' ) ;
21- if ( ! SMTP_USERNAME ) throw new Error ( 'No SMTP user configured' ) ;
22- if ( ! SMTP_PASSWORD ) throw new Error ( 'No SMTP password configured' ) ;
23-
24- const mailer = nodemailer . createTransport ( {
25- host : SMTP_HOST ,
26- port : Number ( SMTP_PORT ) ,
27- secure : true ,
28- auth : {
29- user : SMTP_USERNAME ,
30- pass : SMTP_PASSWORD
31- }
32- } ) ;
33-
3412const THANK_YOU_PAGE = 'https://httptoolkit.com/contact-thank-you/'
3513
3614export const handler = catchErrors ( async ( event ) => {
You can’t perform that action at this time.
0 commit comments