Send Email with Meteor and SendGrid
SendGrid TeamMeteor is a cool new framework for rapidly building modern web applications. At PayPal’s BattleHack in Austin I had the chance to watch David Brear use it. He built a lot of functionality in a short amount time.
In this post, I am going to quickly show you how easy it is to use SendGrid with your Meteor application.
Add The Email Package
Once you have Meteor installed, add the email package.
meteor add email
Setup the MAIL_URL
Next set up the MAIL_URL in server/smtp.js.
touch server/smtp.js
Paste in the following – replacing your_username and your_password.
Meteor.startup(function () {
process.env.MAIL_URL = 'smtp://your_username:your_password@smtp.sendgrid.net:587';
});
Send an Email
In your Meteor code place the following where you want to send the email(s).
if (Meteor.isServer) {
Email.send({
from: "from@mailinator.com",
to: "alpha@mailinator.com",
subject: "Subject",
text: "Here is some text"
});
}
That’s it. Now you are sending emails in your Meteor application using SendGrid!