Tag: sendgrid

Sendgrid事务邮件模板将href属性作为replace

我正在尝试使用sendgrid事务模板来发送信息电子邮件,如帐户validation等,使用sendgrid节点客户端 。 我创build了一个主要的事务模板,它应该有一个button,它具有一个dynamic的正文文本和一个带有每个邮件的dynamicURL / href属性的button。 我replacebutton文本的作品,如果我用URLreplacereplace它,我也看到在文本中的URL。 但是,当我尝试追加url到href属性它消失,它只是从我的锚标签剥离href属性。 这种情况在任何地方都会发生,无论是在可视化构build器中,HTML片段还是在邮件正文中设置buttonURL,都无关紧要。 手动设置一个URL,没有replace,似乎工作。 我也尝试使用%value%作为替代,和多个邮件客户端(Gmail,Outlook),但无济于事。请参阅我的函数发送以下信息电子邮件: const sendInformationalEmail = async (to, subject, body, substitutions) => { const fromMail = new helper.Email(SENDGRID_FROM_MAIL); const toMail = new helper.Email(to); const content = new helper.Content('text/html', body); const mail = new helper.Mail(fromMail, subject, toMail, content); mail.setTemplateId(process.env.SENDGRID_INFORMATIONAL_TEMPLATE_ID); Object.keys(substitutions).map(substitution => { mail.personalizations[0].addSubstitution( new helper.Substitution(`-${substitution}-`, substitutions[substitution]) ); }); const […]

Webtask + Sendgrid =编译失败?

通过webtask.io运行: var sgMail = require("@sendgrid/mail"); module.exports = function(context, req, res) { res.writeHead(200, { 'Content-Type': 'text/html '}); res.end('<h1>Hello, world!</h1>'); }; 结果在这个回应中: { "code": 400, "message": "Compilation failed: Unexpected token {", "error": "Unexpected token {", "stack": "SyntaxError: Unexpected token {\n at exports.runInThisContext (vm.js:53:16)\n at Module._compile (module.js:373:25)\n at Module._compile (/data/sandbox/lib/module.js:127:21)\n at Object.Module._extensions..js (module.js:416:10)\n at Module.load (module.js:343:32)\n at Function.Module._load […]

使用sendgrid发送带有图像的邮件

“上面发送电子邮件的代码是.iam厌倦了我的头,但仍然不能看到邮件中的图像。我将图像转换为base 64编码的string,并且还遵循sendgrid语法仍然无法发送形象。我不知道wats会出错。 var app = require("../../../server/server"); var base64Img = require("base64-img"); let status = null; let textBody, htmBody = null; var DataSource = require("loopback-datasource-juggler").DataSource; var dsSendGrid = new DataSource("loopback-connector-sendgrid", { api_key: app.customConfig.mail.sendgrid.api_key }); var fs = require("fs"); function base64_encode(file) { var bitmap = fs.readFileSync(file); return new Buffer(bitmap).toString("base64"); } function base64_decode(base64str, file) { var bitmap = new […]

使用Express / Sendgrid使用电子邮件模板联系表单

我有一个简单的联系表单使用节点Sendgrid辅助程序库 。 我想使用一个模板email/contact.jade编译为HTML并添加正确的上下文。 我知道它需要去的payload.html值,但我坚持如何发送电子邮件与模板。 routes.js app.route('/contact') .post(function(req, res) { var template = 'email/contact.jade'; var payload = { to: req.body.email, from: 'example@example.com', subject: req.body.subject, html: req.body.message }; var email = new sendgridClient.Email(payload); sendgridClient.send(email, function(err, json) { if (err) { return console.error(err); } else { res.redirect('/thanks'); } }); }); 电子邮件/ contact.jade p Thanks p Name {{ name […]

节点js – 发送基本电子邮件发送电网问题

节点js – 发送基本电子邮件发送电网问题 我已经安装了我的节点js服务器,需要帮助的设置。 错误“无法设置标题” 这是我的代码: var express = require('express'); var router = express.Router(); var sendgrid = require('sendgrid')('IHaveAKey'); router.get('/', function(req, res) { res.sendStatus(200); }); router.get('/welcomeEmail/:email/:name', function(req, res) { var subject = 'Hello' + req.params.name; sendgrid.send({ to: 'test@hotmail.co.uk', from: 'noreply@test.com', subject: 'Test', text: 'Welcome' }, function(err, json) { if (err) { return res.send("Error");} return res.send("Sent"); }); […]

在S3存储桶中附加图像以使用SendGrid发送

我正在使用Xcode 7.3.1在Swift 2.2中编写一个iOS应用程序。 那么,对于我使用AWS Mobilehub ( S3和Lambda )的后端服务, 应用程序应该执行的操作:截取屏幕截图,将其发送到AWS S3存储桶,使用AWS Lambda函数触发器通过SendGrid发送屏幕截图。 我的问题:我似乎无法将S3存储桶中该死的图像附加到电子邮件。 本地它工作正常,但上传到Lambda时会引发以下错误: 错误:ENOENT:没有这样的文件或目录,打开'…' 使用下面的代码: 'use strict'; var fs = require('fs'); console.log('Loading function'); let aws = require('aws-sdk'); let s3 = new aws.S3({ apiVersion: '2006-03-01' }); exports.handler = (event, context, callback) => { // Get the object from the event and show its content type const […]

Sendgrid入站webhook与节点和multer

我试图通过入站webhook使用node,express和multer来存储来自sendgrid的电子邮件。 在sendgrids网站上有一个例子如下: var express = require('express'); var multer = require('multer'); var upload = multer(); var app = express(); app.configure(function(){ app.set('port', process.env.PORT || 3000); app.use(multer()); }); app.post('/parse', upload.array('files', 3) function (req, res) { var from = req.body.from; var text = req.body.text; var subject = req.body.subject; var num_attachments = req.body.attachments; for (i = 1; i <= num_attachments; […]

使用sendgrid如何知道我的电子邮件是否反弹或在我的代码中成功交付

我正在使用Sendgrid npm模块发送电子邮件给我的客户与node.js,现在我面临着一个问题,当我发送一封电子邮件到一个不存在的电子邮件,然后我的电子邮件正在反弹,但在我的服务器响应代码我越来越“成功”,但在我的sendgrid的仪表板它显示我的电子邮件被反弹,现在任何人都可以请告诉我我怎么能知道我的代码是否我的代码反弹或成功发送。 我的代码如下 var options = { auth: { api_user: 'abc', api_key: 'pass' } } var mailer = nodemailer.createTransport(sgTransport(options)); var email = { to: email_id, from: 'noreply@abc.com', subject: 'ABC Verification Code', text: "Your ABC Verification Code is " + totp // html: '<b>Awesome sauce</b>' }; mailer.sendMail(email, function(err, res) { if (err) { console.log(err); res.json({success : […]

如何在log4js smtp appender中使用非SMTP传输?

如果你阅读了SMTP appender的log4js 文档 ,你会看到SMTP传输的例子,它甚至不能和最新的nodemailer(我在写作时使用nodemailer 1.3.0)很好地工作。 文档显示这个不好的configuration为例: { "appenders": [ { "type": "smtp", "recipients": "foo@bar.com", "sendInterval": 60, "transport": "SMTP", "SMTP": { "host": "smtp.gmail.com", "secureConnection": true, "port": 465, "auth": { "user": "foo@bar.com", "pass": "bar_foo" } } } ] } 如何更改configuration使用SMTP以外的传输? 我想要的是configurationlog4js使用SendGrid。

获取250 OK状态从SendGrid发送,但电子邮件永远不会在邮箱中结束

function sendEmailVerification(username, email, destination, response, cb){ // create a random number var email_url = security.createEmailToken(username, email); // create a new URL for the verify call that will go into the email link=PROTOCOL+"://"+destination+"/verify?token="+email_url; // to : request.query.to, var verifyEmail = new sendgrid.Email(); verifyEmail.addTo(email); verifyEmail.setSubject('Verify your email with example.com.'); verifyEmail.setFrom('verify@example.com'); verifyEmail.setText(link); verifyEmail.setHtml(link); verifyEmail.addFilter('templates', 'enable', 1); verifyEmail.addFilter('templates', 'template_id', […]