【问题标题】:How to send email in html form using express js如何使用 express js 以 html 形式发送电子邮件
【发布时间】:2019-07-04 12:23:24
【问题描述】:

我是 nodejs 的新手,我在主页(本地主机上)显示 html 文件,在这个文件中有联系我们的表格,我想向用户发送电子邮件,我该怎么做?这是我当前的代码,在此先感谢

app.set('view engine', 'ejs');
app.use(express.static('public'));

app.get('/', function(req, res){
   res.sendFile(__dirname + '/index.html'); 
});

【问题讨论】:

    标签: javascript node.js express


    【解决方案1】:

    要发送电子邮件,您需要一台 SMTP 服务器,还需要在节点中创建一个电子邮件服务来发送电子邮件。

    其他方式你可以使用 NPM 模块“nodemailer”来发送邮件 https://github.com/niftylettuce/email-templates

    【讨论】:

    • 我的问题不同我想知道我应该使用ejs模板还是jade?如果没有,那么 html 文件中的表单操作是什么?
    猜你喜欢
    • 2012-04-29
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    • 2021-05-11
    • 2010-11-26
    • 2014-06-22
    相关资源
    最近更新 更多