File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,31 @@ export async function GET() {
7
7
try {
8
8
console . log ( "ENTERED TEST EMAIL" ) ;
9
9
const transporter = nodemailer . createTransport ( {
10
- service : "gmail" ,
10
+ port : 465 ,
11
+ host : "smtp.gmail.com" ,
12
+ // service: "gmail",
11
13
auth : {
12
14
user : process . env . EMAIL ,
13
15
pass : process . env . PASSWORD ,
14
16
} ,
17
+ secure : true ,
18
+ } ) ;
19
+ await new Promise ( ( resolve , reject ) => {
20
+ // verify connection configuration
21
+ transporter . verify ( function ( error , success ) {
22
+ if ( error ) {
23
+ console . log ( error ) ;
24
+ reject ( error ) ;
25
+ } else {
26
+ console . log ( "Server is ready to take our messages" ) ;
27
+ resolve ( success ) ;
28
+ }
29
+ } ) ;
15
30
} ) ;
16
31
console . log ( "CREATED TRANSPORTER" ) ;
17
32
const emailHtml = render (
18
33
FeedbackEmail ( {
19
- name : "TESTING01 " ,
34
+ name : "TESTING02 " ,
20
35
email : "asdf" ,
21
36
message : "Testing email in production" ,
22
37
} )
@@ -28,7 +43,18 @@ export async function GET() {
28
43
html : emailHtml ,
29
44
} ;
30
45
console . log ( "CREATED OPTIONS" ) ;
31
- transporter . sendMail ( options ) ;
46
+ await new Promise ( ( resolve , reject ) => {
47
+ // send mail
48
+ transporter . sendMail ( options , ( err , info ) => {
49
+ if ( err ) {
50
+ console . error ( err ) ;
51
+ reject ( err ) ;
52
+ } else {
53
+ console . log ( info ) ;
54
+ resolve ( info ) ;
55
+ }
56
+ } ) ;
57
+ } ) ;
32
58
console . log ( "SENT EMAIL" ) ;
33
59
return NextResponse . json ( { message : "Success" } , { status : 200 } ) ;
34
60
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments