Nyc*_*Sci 277 email-integration node.js
我最近开始编程我的第一个node.js. 但是,我发现我无法创建直接发送到我的电子邮件的联系人表单,因为我找不到任何能够发送电子邮件的节点的模块.
有谁知道node.js电子邮件库或示例联系表单脚本?
小智 159
Nodemailer基本上是一个模块,使您能够在Node.js中编程时轻松发送电子邮件.有一些关于如何在http://www.nodemailer.com/上使用Nodemailer模块的很好的例子.有关如何安装和使用Nodemailer基本功能的完整说明,请参见此链接.
我个人在使用npm安装Nodemailer时遇到了麻烦,所以我刚刚下载了源代码.有关npm安装和下载源的说明.
这是一个非常简单的模块,我建议任何想要使用Node.js发送电子邮件的人.祝好运!
小智 140
node-email-templates是一个更好的选择:https: //github.com/niftylettuce/node-email-templates
它也支持Windows
sil*_*vio 64
看看emailjs
在浪费了大量时间尝试使用大型附件进行nodemailer工作之后,发现了emailjs并且从此开心.
它支持使用普通的File对象发送文件,而不是像nodemailer所要求的那样使用巨大的Buffers.意味着你可以将它链接到fe,强大,以便将附件从html表单传递给邮件程序.它还支持排队..
总而言之,不知道为什么nodejitsu ppl选择了nodemailer来建立他们的版本,emailjs更加先进.
Vic*_*cky 51
使用nodemailer模块完成代码以发送电子邮件
var mailer = require("nodemailer");
// Use Smtp Protocol to send Email
var smtpTransport = mailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "gmail_id@gmail.com",
pass: "gmail_password"
}
});
var mail = {
from: "Yashwant Chavan <from@gmail.com>",
to: "to@gmail.com",
subject: "Send Email Using Node.js",
text: "Node.js New world for me",
html: "<b>Node.js New world for me</b>"
}
smtpTransport.sendMail(mail, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
smtpTransport.close();
});
Run Code Online (Sandbox Code Playgroud)
Dea*_*her 25
@ JimBastard接受的答案似乎已过时,我看了一下,邮件库已经超过7个月未被触及,列出了几个错误,并且不再在npm注册.
nodemailer肯定看起来是最好的选择,但是在这个帖子的其他答案中提供的url都是404'ing.
nodemailer声称支持轻松插入gmail,hotmail等,并且还有非常漂亮的文档.
你总是可以使用AlphaMail(披露:我是其背后的开发者之一).
只需安装NPM:
npm install alphamail
Run Code Online (Sandbox Code Playgroud)
注册一个AlphaMail帐户.获取令牌,然后您可以开始使用AlphaMail服务发送.
var alphamail = require('alphamail');
var emailService = new alphamail.EmailService()
.setServiceUrl('http://api.amail.io/v1/')
.setApiToken('YOUR-ACCOUNT-API-TOKEN-HERE');
var person = {
id: 1234,
userName: "jdoe75",
name: {
first: "John",
last: "Doe"
},
dateOfBirth: 1975
};
emailService.queue(new alphamail.EmailMessagePayload()
.setProjectId(12345) // ID of your AlphaMail project (determines template, options, etc)
.setSender(new alphamail.EmailContact("Sender Company Name", "from@example.com"))
.setReceiver(new alphamail.EmailContact("John Doe", "to@example.org"))
.setBodyObject(person) // Any serializable object
);
Run Code Online (Sandbox Code Playgroud)
在AlphaMail GUI(仪表板)中,您将能够使用您发送的数据编辑模板:
<html>
<body>
<b>Name:</b> <# payload.name.last " " payload.name.first #><br>
<b>Date of Birth:</b> <# payload.dateOfBirth #><br>
<# if (payload.id != null) { #>
<a href="http://company.com/sign-up">Sign Up Free!</a>
<# } else { #>
<a href="http://company.com/login?username=<# urlencode(payload.userName) #>">Sign In</a>
<# } #>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
模板是用Comlang编写的,它是一种专门为电子邮件设计的简单模板语言.
小智 6
Nodemailer模块是在node.js中发送电子邮件的最简单方法.
试试这个示例示例表单:http://www.tutorialindustry.com/nodejs-mail-tutorial-using-nodemailer-module
其他信息:http://www.nodemailer.com/
归档时间: |
|
查看次数: |
249490 次 |
最近记录: |