您可以通过两种方式设置from参数:
var SendGrid = require('sendgrid').SendGrid;var sendgrid = new SendGrid(user, key);sendgrid.send({ to: 'you@yourdomain.com', from: 'example@example.com', // Note that we set the `from` parameter here fromname: 'Name', // We set the `fromname` parameter here subject: 'Hello World', text: 'My first email through SendGrid'}, function(success, message) { if (!success) { console.log(message); }});或者您可以创建一个
var Email = require('sendgrid').Email;var email = new Email({ to: 'you@yourdomain.com', from: 'example@example.com', fromname: 'Name', subject: 'What was Wenger thinking sending Walcott on that early?', text: 'Did you see that ludicrous display last night?'});sendgrid.send(email, function() { // ... });您可能需要花几分钟时间浏览Github页面上的README文档。它具有有关如何使用该库及其提供的各种功能的非常详细的信息。



