带环回 3 的电子邮件连接器

Email connector with loopback 3

我有一个联系表,正在使用 PersistedModel 存储在 mysql table 中。现在我想发送包含表单值的电子邮件。这该怎么做。我试过使用环回 3 电子邮件连接器,但没有任何效果,我不知道该怎么做。谁能举个例子。

 <form class="form-area contact-form text-right" name="myForm" id="myForm"  novalidate >
                     <div class="row">
                        <div class="col-lg-6 form-group">
                           <input name="name" id="name" placeholder="Enter your name" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your name'" class="common-input mb-20 form-control" required="" type="text">
                           <input name="email" id="email" placeholder="Enter email address" pattern="[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{1,63}$" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter email address'" class="common-input mb-20 form-control" required="" type="email">
                            <div class="invalid-feedback">Please Enter a Valid Email Id.</div>
                           <input name="subject" id="subject" placeholder="Enter your subject" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your subject'" class="common-input mb-20 form-control" required="" type="text">
                           <div class="mt-20 alert-msg" style="text-align: left;"></div>
                        </div>
                        <div class="col-lg-6 form-group">
                           <textarea class="common-textarea form-control" name="message" id="message" placeholder="Message" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Message'" required=""></textarea>
                           <button type="submit" class="primary-btn mt-20 text-white" style="float: right;">Send Message</button>
                        </div>
                     </div>
                 </form>

脚本:

<script type='text/javascript'>
         $("#myForm").submit(function(e) {
            var ins_date=new Date($.now()).toLocaleString();
         var parms = {
         name : $("#name").val(),
         email : $("#email").val(),
         subject : $("#subject").val(),
         message: $("#message").val(),
         inserted_date:ins_date
         };
         var url2="http://localhost:3000/api";
         $.ajax({
         method: 'POST',
         url: url2 + "/contacts",
         async: false,
         dataType : "json",
         contentType: "application/json; charset=utf-8",
         data: JSON.stringify(parms),
         success: function(result){
         console.log('Submission was successful.');
         location.reload();
         console.log(data);
         }, error: function (data) {
            console.log('An error occurred.');
            console.log(data);
               },   
            })
      });
      </script>

datasource.json

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "mysql": {
    "host": "localhost",
    "port": 3306,
    "url": "",
    "database": "mydb",
    "password": "pass",
    "name": "mysql",
    "user": "root",
    "connector": "mysql"
  },
 "email": {
    "name": "email",
    "connector": "mail",
    "transports": [
      {
        "type": "smtp",
        "host": "mail.company.com",
        "secure": true,
        "port": 465,
        "tls": {
          "rejectUnauthorized": false
        },
        "auth": {
          "user": "email@address.com",
          "pass": "password"
        }
      }
    ]
  }
}

在环回中添加电子邮件数据源。在afterRemote函数中写发送邮件函数。