- Best Practices
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
We’ve been big fans of Meteor since they launched because it was clear they shared our passion for making developers lives’ easier. That’s why we wanted to make sure we partnered with them to enable transactional email on their platform. When you add the Meteor smart package for email, you gain access to Meteor’s email API for use with any standard SMTP server. Not only that but if you deploy your app using meteor deploy on the Meteor platform (there are thousands already), it AUTOMATICALLY comes with a Mailgun account. No configuration whatsoever is required to start sending app emails that actually get delivered to your user’s inbox.
Meteor was built to solve real problems that web app developers face all the time. In Meteor, you write your entire application in JavaScript, both the client part and the server part. You can get an application up and running fast, because you only need to think in one language and one API.
Meteor solves a lot of other hard parts of writing modern, rich web applications. It automatically redraws the screen when underlying data changes, so that you don’t have to write any template redrawing code. It gives you a single, consistent database API on the client and the server. And it includes hot code pushes, so that you can continuously deploy changes to your application without interrupting all your signed-in users. (This is becoming more important now as more and more apps run in the browser rather than in the server.)
At the beginning of this post, we mentioned that Meteor offers a native integration for Mailgun. That means that when you add the email package to your Meteor project and use meteor deploy, you will automatically be able to send up to 300 emails per day through Mailgun without having to create a separate Mailgun account or enter any SMTP credentials. Simply use the email.send function and define the structure of the email (to:, from:, subject:; text: or html:). For example, to send a simple text-only email, you’d could use:
Email.send({
from: fromEmail,
to: toEmail,
replyTo: fromEmail,
subject: "That was easy",
text: "If you're reading this, sending an email through Meteor really was that easy"
});
If you want to send an email from the client, instead of the server, this is possible too. You just define a method on the server and call it from the client. This would be useful, for example, if you were building a social app where actions that a user takes in the client should trigger sending an email to other users, similar to the way Facebook allows users to receive email when their friends like or comment a post.
// In your server code: define a method that the client can call
Meteor.methods({
sendEmail: function (to, subject, text) {
// Let other method calls from the same client start running,
// without waiting for the email sending to complete.
this.unblock();
// don’t allow sending email unless the user is logged in
if (!Meteor.user())
throw new Meteor.Error(403, “not logged in”);
// and here is where you can throttle the number of emails this user
// is allowed to send per day
Email.send({
to: to,
from: Meteor.user().emails[0].address,
subject: subject,
text: text
});
}
});
// In your client code: asynchronously send an email
Meteor.call('sendEmail',
'alice@example.com',
'Hello from Bob!',
'This is a test of Email.send.');
In an actual application, you’d need to be careful to limit the emails that a client could send, to prevent your server from being used as a relay by spammers. By calling email.send method inside a method on the server, you get the ability to easily handle access control and rate limiting for clients.
If you want to send more than 300 emails per day through Meteor, that is possible too and simply requires you to signup for a Mailgun account. We’ll have another post soon describing how that process works and how we envision integrating even more deeply in the future as Meteor moves towards general availability.
What you you like to see in a Mailgun-Meteor integration? Leave your ideas in this blog comments or on Hacker News. We’d love to hear them.
Learn about our Deliverability Services
Looking to send a high volume of emails? Our email experts can supercharge your email performance. See how we've helped companies like Lyft, Shopify, Github increase their email delivery rates to an average of 97%.
Last updated on October 05, 2021
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
How to Improve Holiday Supply Chain Communication with Email
The Difference Between SMTP and API
The Basics of Email Dark Mode
COVID-19 Survey: How the Pandemic Has Affected Email Sending
The Top Email Clients and Email Apps of 2021
The Benefits of Email Automation
Mailgun Just Got Better For Client Management
How To Avoid Emails Going To Spam
Understanding DKIM: How It Works and Why It's Necessary
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Become an Email Pro With Our Templates API
Google Postmaster Tools: Understanding Sender Reputation
Navigating Your Career as a Woman in Tech
Implementing Dmarc – A Step-by-Step Guide
Email Bounces: What To Do About Them
Announcing InboxReady: The deliverability suite you need to hit the inbox
Black History Month in Tech: 7 Visionaries Who Shaped The Future
How To Create a Successful Triggered Email Program
Designing HTML Email Templates For Transactional Emails
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Implementing Dmarc – A Step-by-Step Guide
Announcing InboxReady: The deliverability suite you need to hit the inbox
Designing HTML Email Templates For Transactional Emails
Email Security Best Practices: How To Keep Your Email Program Safe
Mailgun’s Active Defense Against Log4j
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
Email's Best of 2021
5 Ideas For Better Developer-Designer Collaboration
Mailgun Joins Sinch: The Future of Customer Communications Is Here
Always be in the know and grab free email resources!
By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.