require('dotenv').load();
var fs = require('fs');
var sendgrid_username = process.env.SENDGRID_USERNAME;
var sendgrid_password = process.env.SENDGRID_PASSWORD;
var from = process.env.FROM;
var from_name = process.env.FROM_NAME;

var app = require('express')();
app.post('/vp', function(req, res) {
  var multiparty = require('multiparty');
  var form = new multiparty.Form();
  form.parse(req, function(err, fields, files){
      console.log(require('util').inspect(fields, false));

      fs.readFile('./mail.txt', 'utf8', function(err, text) {
        var sender = fields.from[0];
        var subject = fields.subject;
        var reg = /[A-Za-z0-9\-\.\_]+@[A-Za-z0-9\-\_]+\.[A-Za-z0-9\-\.\_]+/;
        var email = sender.match(reg);
        var sendgrid = require('sendgrid')(sendgrid_username, sendgrid_password);
        var sgMail = new sendgrid.Email();
        sgMail.addTo(email);
        sgMail.setFrom(from);
        sgMail.fromname = from_name;
        sgMail.setSubject('Re: ' + subject);
        sgMail.setText(text + '\r\n' + from_name + '\r\n' + from);
        sendgrid.send(sgMail, function(err, json){
          if (err) { return console.error(err);}
          console.log(json);
        });
      });
  }); 
  res.send('');
});

app.listen(process.env.PORT || 7076);

@@ -291,16 +291,37 @@
  res) %7B%0A
+  var err;%0A  try %7B%0A  
   var mu
@@ -354,16 +354,18 @@
 arty');%0A
+  
   var fo
@@ -394,16 +394,18 @@
 rm();%0A  
+ 
+ 
 form.par
@@ -442,16 +442,18 @@
 files)%7B%0A
+  
       co
@@ -510,16 +510,18 @@
 %0A%0A      
+ 
+ 
 fs.readF
@@ -568,16 +568,18 @@
 text) %7B%0A
+  
         
@@ -611,24 +611,26 @@
 0%5D;%0A        
+  
 var subject 
@@ -647,16 +647,18 @@
 ubject;%0A
+  
         
@@ -730,24 +730,26 @@
 +/;%0A        
+  
 var email = 
@@ -767,16 +767,18 @@
 h(reg);%0A
+  
         
@@ -855,24 +855,26 @@
 d);%0A        
+  
 var sgMail =
@@ -892,24 +892,26 @@
 id.Email();%0A
+  
         sgMa
@@ -927,32 +927,34 @@
 email);%0A        
+  
 sgMail.setFrom(f
@@ -963,24 +963,26 @@
 m);%0A        
+ 
+ 
 sgMail.fromn
@@ -998,16 +998,18 @@
 m_name;%0A
+  
         
@@ -1045,32 +1045,34 @@
 bject);%0A        
+ 
+ 
 sgMail.setText(t
@@ -1122,16 +1122,18 @@
         
+  
 sendgrid
@@ -1177,16 +1177,18 @@
         
+ 
+ 
 if (err)
@@ -1220,32 +1220,34 @@
 rr);%7D%0A          
+  
 console.log(json
@@ -1257,20 +1257,24 @@
         
+  
 %7D);%0A
+  
       %7D)
@@ -1279,15 +1279,70 @@
 %7D);%0A
+  
   %7D); %0A
+  %7D catch (e) %7B%0A    console.log(e);%0A    err = e;%0A  %7D%0A
   re
@@ -1352,10 +1352,11 @@
 end(
-''
+err
 );%0A%7D

Add error case