File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import  assign  from  'object-assign' ; 
2+ import  nodemailer  from  'nodemailer' ; 
3+ import  configs  from  '../../../configs/project/server' ; 
4+ 
5+ let  defaultTransport  =  ( 
6+   `smtps://${ configs . gmail [ process . env . NODE_ENV ] . username }  %40gmail.com:`  + 
7+   `${ configs . gmail [ process . env . NODE_ENV ] . password }  @smtp.gmail.com` 
8+ ) ; 
9+ 
10+ export  default  ( transport  =  defaultTransport )  =>  { 
11+   let  transporter  =  nodemailer . createTransport ( transport ) ; 
12+   return  { 
13+     sendMail : ( mailOptions )  =>  new  Promise ( ( resolve ,  reject )  =>  { 
14+       mailOptions  =  assign ( 
15+         { } , 
16+         configs . mailOptions . default , 
17+         configs . mailOptions [ process . env . NODE_ENV ] , 
18+         mailOptions 
19+       ) ; 
20+       transporter . sendMail ( mailOptions ,  ( err ,  info )  =>  { 
21+         if  ( err )  { 
22+           return  reject ( err ) ; 
23+         } 
24+         return  resolve ( info ) ; 
25+       } ) ; 
26+     } ) , 
27+   } ; 
28+ } ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments