发送AngularJS构成对NodeMailer发送电子邮件 [英] Sending AngularJS form to NodeMailer to send email

查看:1447
本文介绍了发送AngularJS构成对NodeMailer发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个内置的电子邮件的形式在使用包含字段发送电子邮件,邮件收件人,主题和邮件内容An​​gularJS一个模式实例。该表单使用输入框和NG-模型来跟踪数据。当用户点击该表格上的发送按钮,我想送所有的车型收集到服务器中的信息来发送电子邮件。

I have a built an email form in a modal instance using AngularJS that contains the field sending email, recipient email, subject, and email content. The form uses input boxes and ng-models to keep track of the data. When the user hits the send button on this form, I would like to send all of the information collected by the models to the server to send an email.

目前,我有一个按钮草案,当用户点击该按钮草案,我把所有的模型中收集到一个控制器谁把它发送给一个服务,如果用户决定,我可以重新填充信息的信息关闭模式的实例,以后要发送电子邮件。但是,如果用户点击发送按钮,我有所有的信息,该对象,但不知道如何将它发送到服务器。我很新的一般的Node.js和后端所以如果你有人可以提供一个具体的简短的例子对我来说,从学习将是巨大的。

Currently, I have a draft button and when the user hits the draft button, I send all of the information collected in the models to a controller who sends it to a service so that I can repopulate the information if the user decides to close the modal instance and send the email later. However, if the user hits the send button, I have this object with all of the information but don't know how to send it to the server. I'm very new to node.js and backend in general so if you someone could provide a concrete short example for me to learn from that would be great.

我希望利用我所使用NPM安装nodemailer模块。

I'm looking to use the nodemailer module which I have installed using npm.

谢谢!

推荐答案

在节点侧可以以收到来自服务器的模式对话框的形式提交电子邮件的POST请求创建一个REST终点。其余的终点会是这样的,如果你有一个前preSS服务器。

At the node side you can create a REST end point in order to recieve a POST request from the server for the form submission of email in the modal box. The REST end-point will look like this if you have an express server.

var express = require('express');
var router = express.Router();
var app = express();
app.post('/postEmail',function(req,res){
    //Your NodeMailer logic comes here
});

在角部分,就像你写了一个服务,你可以创建一个角度工厂来调用这个REST终点。

In the angular part, just like you have written a service, you can create an angular factory to invoke this REST end point.

例如:

myApp.factory('postEmailForm',['$http',function($http){
   return {
     postEmail: function(emailData,callback){
       $http.post("/postEmail/", emailData).success(callback);  
     }
   }
}]);

在这里对myApp是你的角模块,emailData是你要发送到服务器的数据emailForm(它会被张贴在请求的主体)

where myApp is your angular module, emailData is the emailForm data which you want to send to the server (it will be posted in the body of the request)

这篇关于发送AngularJS构成对NodeMailer发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆