Tag: sendgrid

Nodemailer HTML不能与sendgrid一起工作

我正在使用sendgrid和nodemailer试图发送一个HTML电子邮件。 这里是代码: for(var i = 0;i<emails.length; i++){ email.sendMail({ from:'"Name" <noreply@domain.com>', to:emails[i], HTML:"<h1>hi</h1>", generateTextFromHTML:true, subject: "Blah" },function(err,res){ if(err){console.log(err)}; if(res){console.log(res.message)}; }) } 让我知道如果你需要更多的信息让我知道。 谢谢,阿里

Node.js和Sendgrid邮件程序错误

我对节点有点新鲜 我使用express和sendgrid api发送电子邮件(完全收集REST)。 在sendgrid成功或失败之后,我想用一个json对象来响应。 以下是示例情况: var SendGrid = require('sendgrid-nodejs').SendGrid; var sendgrid = new SendGrid(user, key); app.get('/LGP/:email', function (req, res){ sendgrid.send({ to: req.params.email, from: 'me@example.com', subject: 'Hello World', text: 'This email sent through SendGrid' }, function(success, message) { if (!success) { console.log(message); } else { res.writeHead(200, { 'Content-Type': 'application/json' }); res.write(JSON.stringify({ result: 'success' })); res.end(); //error […]

Node.jscallback调用两次

我为node.js使用sendgrid库。 目前有一个callback,它被炒了两次。 @invite = (email, agencyId, callback) -> (app.get 'agencies').findOne {_id: agencyId}, {name:1}, (error, agency) -> sendgrid.send { to: email, from: 'yamil.asusta@upr.edu', subject: "You have been invited to #{agency.name}", html: "<html><body>Have fun</a></body></html>" }, (success, message) -> console.log arguments if success console.log callback callback() else console.log message 这是我从控制台得到的 { '0': true, '1': undefined } [Function] { […]

使用sendgrid npm添加附件不起作用

我正在使用sendgrid Node.js模块发送电子邮件。 我有一个文件已经在服务器上,并希望将其添加到电子邮件的附件。 我发现电子邮件通过,但没有附件,所以不知道发生了什么问题。 //sendgrid credentials var mailer = nodemailer.createTransport(sendGrid({ auth: { api_user: conf.mail.user, api_key: conf.mail.pass } })); //mail object var mailObj = { to: toAddr, from: fromAddr, subject: subject, html: template, files: [{ path: __dirname + "/../../uploads/" + filename }] }; //send mail mailer.sendMail(mailObj, function(err, res){ if (err) throw err; }); 上面是包含在一个更大的函数,通过包括filenamevariables。 需要牢记的是: 文件名被传递给函数 […]

Sendgrid API:“提供的授权许可无效,过期或被吊销”

我已经挖过了过去的post,似乎没有什么解决这个问题。 我正在使用生成的API密钥(不是API密钥ID),我已经允许所有权限,甚至尝试打开第二个帐户并从那里尝试。 这里是代码: // Create new mail object. var mail = new helper.Mail(); // Set 'from' for email. var from = new helper.Email("owner@site.com", "First Last"); mail.setFrom(from) // Set 'subject' for email. mail.setSubject("SchemeBeam Email Verification"); // Create a new personalization, which will allow us to define // an individual to send this email too, as well […]

Sendgrid v3邮件返回202,但电子邮件不发送

我正尝试通过Sendgrid发送电子邮件validation给已经注册了第一个的用户。 遵循这里find的v3_mail示例,我创build了以下实现: const querystring = require('querystring'); const helper = require('sendgrid').mail; const https = require('https'); const url = "http://<mywebsite.com>/users/reset/passwordLoggedOut?"; let sg = require('sendgrid')(process.env.SENDGRID_API_KEY); const emails = {}; function sendMail(mail){ const request = sg.emptyRequest({ method: 'POST', path: '/v3/mail/send', body: mail.toJSON(), }); sg.API(request, function(error, response) { console.log(response.statusCode); console.log(response.body); console.log(response.headers); console.log(error); }); } emails.sendActivationEmail = function(user){ let qso = […]

更长的Nodemailer Html /文本

nodemailer的每个例子都是这样的: var mailOptions = { from: "Fred Foo ✔ <foo@blurdybloop.com>", // sender address to: "bar@blurdybloop.com, baz@blurdybloop.com", // list of receivers subject: "Hello ✔", // Subject line text: "Hello world ✔", // plaintext body html: "<b>Hello world ✔</b>" // html body} 当有人报名时,我想要比单class轮换更长的信息。 有没有办法在我的应用程序的另一个地方编写和源代码的HTML,所以也许只是一系列的换行符。 TL; DR 我想让nodemailer发送比单线更长的邮件

发送消息时,Sendgrid SMTP API不会replacereplace标记

我正在开发一个Node.js应用程序,它将Sendgrid事务电子邮件模板包含在用户邀请函中。 具体来说,我使用Ubuntu w /官方sendgrid v2 npm上的nodejs v0.10.25。 我实际发送消息的function如下: function sendEmail(payload, options, cb){ //for debugging purposes console.log(options); var email = new sendgrid.Email({ subject: payload.subject, html: payload.html, from: global.config.sendgrid.mailFrom, fromname: global.config.sendgrid.mailName, replyto: options.replyto ? options.replyto : 'no-reply@' + global.config.sendgrid.mailhost }); email.setSmtpapiTos(options.addressees); if(options.filters) email.setFilters(options.filters); if(options.subs) email.setSubstitutions(options.subs); if(options.category) email.setCategories(options.category); if(options.unique_args) email.setUniqueArgs(options.unique_args); sendgrid.send(email, function(err, json){ return cb(err, json); }); } […]

sendgrid使testing引发错误

我在我的vps服务器上运行节点。 节点在我的根,我的app.js与node_modules(express,socket.io)在/ home / vps / public_html / 当下面的github自述设置sendgrid我遇到了麻烦: config.js不是由它的声音生活,因为当我运行sendgrids简单的代码示例,如果我 a。)通过下列步骤引用config.js: var sendgrid=new SendGrid(user,key); 节点因为用户没有定义而杀死自己。 b)通过执行以下操作绕过config.js: var sendgrid=new SendGrid({user:'my_user_name',key:'my_password'}); 我得到['Permission denied,wrong credentials']的console.log(消息) 这是另一个图像,这是我的public_html结构: 有没有人知道如何激活这个config.js? 我应该在一开始就在我的public_html中安装了node.js吗?

node.js sendgrid如何附加pdf

我使用sendgrid在我的node.js应用程序中发送电子邮件。 我试图附上一个pdf的每一个组合都以我附加的pdf不可读取而告终。 我试过了: fs.readFile('public_html/img/Report.pdf',function(err,data){ var base64data = new Buffer(data).toString('base64'); sendgrid.send({ to : hexDecode(_.e), from : 'xxxxxxxxx@gmail.com', subject : 'Report', files : [{filename:'Report.pdf',content:'data:application/pdf;base64,'+base64data}], //files : [{filename:'Report.pdf',contentType:'data:application/pdf',url:'public_html/img/'Report.pdf'}], //files : [{filename:'Report.pdf',url:'public_html/img/'Report.pdf'}], html : 'bla bla' 有谁知道如何防止“加载PDF文档失败?