Newsletter
This package automatically generates and sends a newsletter for posts and comments on a predefined schedule.
Every x
days, it builds a digest consisting of the top y
items posted in the past x
days that haven’t yet been sent out in a newsletter. It then sends the campaign, and sends you a confirmation email.
Note: this package requires using a third-party email provider (MailChimp and Sendy are currently supported).
Install
meteor add vulcan:newsletter
Dependencies
Vulcan Dependencies
- vulcan:core
- vulcan:posts
- vulcan:comments
- vulcan:categories
- vulcan:email
NPM Dependencies
Settings
1 | "newsletter": { |
enabled
: enable/disable automated newsletter sending.enabledInDev
: enable/disable newsletter while in development mode.autoSubscribe
: automatically subscribe every new user to your newsletter.frequency
: which days the newsletter should go out.1
is Monday,2
is Tuesday, etc.time
: what time the newsletter should go out.provider
: the name of your newsletter provider.
Sendy Settings
server
: The URL to your self-hosted Sendy server (including trailing/
).apiKey
: Your API key.listId
: List ID.fromName
: “From” name.fromEmail
: “From” email.replyTo
: “Reply to” email.
MailChimp Settings
apiKey
: Your API key.listId
: List ID.
Test Routes
If you want to preview your email templates, you can do so at the following routes:
- Campaign: http://localhost:3000/email/newsletter
- Confirmation: http://localhost:3000/email/newsletter-confirmation
(Replace http://localhost:3000
with your app’s URL)
Mutations
The package exposes the following GraphQL mutations:
sendNewsletter
: generate and send the next newsletter.testNewsletter
: same assendNewsletter
, but without marking posts as sent.addUserNewsletter(userId: String)
: add a user to your subscriber list.addEmailNewsletter(email: String)
: add an email to your subscriber list.removeUserNewsletter(userId: String)
: remove a user from your subscriber list.
You can call these mutations from any React component using the withMutation
HoC:
1 | import React, { PropTypes, Component } from 'react'; |
Providers
To add a provider, you can start from the sample.js
template included in the package.
Any new provider must implement the following methods:
Newsletters.providerName.subscribe(email)
: subscribe an email to your list.Newsletters.providerName.unsubscribe(email)
: unsubscribe an email from your list.Newsletters.providerName.send({ title, subject, text, html, isTest})
: send a newsletter.
NewsletterSubscribe Component
This package also exports a NewsletterSubscribe
custom form field component used to add a subscribe/unsubscribe button to the user account page.
Settings
Setting | Example | Description |
---|---|---|
enabled | false | Enable the automated newsletter |
enabledInDev | false | Enable the automated newsletter while in development mode |
frequency | [1,2,3,4,5,6,7] | The days on which to send the newsletter (1 = Monday, 2 = Tuesday, etc.) |
time | “07:55” | When to send out the newsletter |
autoSubscribe | false | Whether new users should be automatically subscribed to the newsletter |