2015-10-17 19 views
0

尝试在Node.js中的Bluemix编码中使用SendGrid服务。我使用addCc()方法向cc添加地址。我没有收到错误消息,邮件已发送到主地址,但没有任何内容发送到cc:ed地址。如果我看到主要收件人的邮件顶部,我可以在那里看到cc地址。有没有人知道在使用cc与SendGrid时是否存在错误或限制?使用Bluemix中的SendGrid服务进行绑定

此致

W¯¯

+0

我假设你正在使用的“sendgrid” NPM模块。什么版本?难道是你打了https://github.com/sendgrid/sendgrid-nodejs/issues/162?看起来应该在最近的版本中修复它。 – jimmc

回答

1

一个常见的错误是当它需要一个字符串传递一个阵列到addCc()函数。使用'sendgrid'npm模块的v2.0.0,下面的代码将正确地发送一个cc的'[email protected]'的电子邮件。

正如评论上面提到的,确认没有用完的问题https://github.com/sendgrid/sendgrid-nodejs/issues/162

// Pre-req: get the SendGrid credentials for username and password 
// from VCAP_SERVICES into the 'user' and 'pass' vars 
var sendgrid = require('sendgrid')(user, pass); 
var email = new sendgrid.Email({ 
    to:  '[email protected]', 
    from: '[email protected]', 
    subject: 'SendGrid Test', 
    text: 'This is a SendGrid test' 
}; 

// add a cc address as a single string 
email.addCc('[email protected]'); 

sendgrid.send(email, function(err, json) { 
    if (err) { 
     return console.error(err); 
    } 
    console.log(json); 
} 
+0

我用过1.9.2。我通过直接更新变量(例如mail.cc = ccAdress)而不是使用方法来解决我的问题。 thnx每个人的提示和技巧。非常感谢W –

相关问题