【问题标题】:Azure SendGrid connected to create-react-app for UIAzure SendGrid 连接到 UI 的 create-react-app
【发布时间】:2018-07-10 05:30:34
【问题描述】:
所以我在 Azure 中使用 create-react-app 创建了我的应用程序,但需要添加提交表单后发送邮件的功能。我知道这不能在我的反应应用程序中完成,但是暂时远离后端工作,我试图在网上搜索一个教程或可以指导我的东西,并使用 sendgrid 设置某种node.js 以便这个UI 现在可以处理使用我的表单发送电子邮件。你们中的任何人都可以推荐一些方向、教程等...来帮助解决这个问题,因为我在 Sendgrid 网站上没有看到这方面的内容。
感谢您的帮助。
【问题讨论】:
标签:
node.js
reactjs
azure
email
sendgrid
【解决方案1】:
查看库 sendgrid-nodejs repo,其中包含 Node.js 的详细示例:
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: 'test@example.com',
from: 'test@example.com',
subject: 'Sending with SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);
对于更复杂的用例,请参阅USE_CASES.md。