Fetching contributors…
Cannot retrieve contributors at this time
62 lines (50 sloc) 1.99 KB
title description
Documentation of Meteor's email API.

The email package allows sending email from a Meteor app. To use it, add the package to your project by running in your terminal:

meteor add email

The server reads from the MAIL_URL environment variable to determine how to send mail. The MAIL_URL should reference an SMTP server and use the form smtp://USERNAME:PASSWORD@HOST:PORT or smtps://USERNAME:PASSWORD@HOST:PORT. The smtps:// form (the s is for "secure") should be used if the mail server requires TLS/SSL (and does not use STARTTLS) and is most common on port 465. Connections which start unencrypted prior to being upgraded to TLS/SSL (using STARTTLS) typically use port 587 (and sometimes 25) and should use smtp://. For more information see the Nodemailer docs

If MAIL_URL is not set, Email.send outputs the message to standard output instead.

{% apibox "Email.send" %}

You must provide the from option and at least one of to, cc, and bcc; all other options are optional.

Email.send only works on the server. Here is an example of how a client could use a server method call to send an email. (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.)

// Server: Define a method that the client can call.
  sendEmail(to, from, subject, text) {
    // Make sure that all arguments are strings.
    check([to, from, subject, text], [String]);

    // Let other method calls from the same client start running, without
    // waiting for the email sending to complete.

    Email.send({ to, from, subject, text });

// Client: Asynchronously send an email.
  'Alice <>',
  'Hello from Meteor!',
  'This is a test of Email.send.'