Implement a way to get/set the nodemailer object (has an entries for contact, feedbac...
[ndcode_site.git] / api / contact / send_enquiry.json.jst
index 04ac3b0..f1e5598 100644 (file)
@@ -1,10 +1,7 @@
-let crypto = require('crypto')
+let nodemailer = require('nodemailer')
 let XDate = require('xdate')
 
 return async env => {
-  let nodemailer_contact = await env.site.get_nodemailer(
-    '/_config/nodemailer_contact.json'
-  )
   let post_request = await _require('/_lib/post_request.jst')
   let session_cookie = await _require('/_lib/session_cookie.jst')
   let Problem = await _require('/_lib/Problem.jst')
@@ -34,12 +31,16 @@ return async env => {
         )
 
       let transaction = await env.site.database.Transaction()
-      let contact_from, contact_to
+      let nodemailer_contact, contact_from, contact_to
       try {
         // initialize env.session_key, set cookie in env.response
         session_cookie(env, transaction)
 
-        let globals = await (await transaction.get({})).get('globals')
+        let root = await transaction.get({})
+        nodemailer_contact = nodemailer.createTransport(
+          await (await root.get('nodemailer')).get_json('contact')
+        )
+        let globals = await root.get('globals')
         contact_from = await globals.get_json('contact_from')
         contact_to = await globals.get_json('contact_to')