Simply sends emails via built-in Email.send method, but with support of HTML-templates and SMTP.
If there is error with email sending, like connection to SMTP, - letter will be placed into queue and tried to send it 50 times after 60 seconds.
Meteor.mail = new Meteor.Mailer options
options
{Object} - Object with next properties:
login
{String} - [required] Your login on SMTP server, ex.:no-reply
host
{String} - [required] Domain name or IP-address of SMTP server, ex.:smtp.example.com
connectionUrl
{String} - [required] Connection (auth) URL with login, password and port, ex.:smtp://account:[email protected]:465
accountName
{String} - Name of the account (usually shown next to or instead of email address). By default equals tologin
property, ex.:Some Service Name Support
intervalTime
{Number} - How often try to send an email in seconds. By default60
seconds, ex.:600
retryTimes
{Number} - How many times to retry to send email. By default50
, ex.:10
saveHistory
{Boolean} - Save sent emails. By defaultfalse
, ex.:true
verbose
{Boolean} - Show messages of sending/pending into server's console. By defaultfalse
, ex.:true
template
{String} - Path to html template, ex.:emailTemplates/signUp.html
- if is not set, email will be sent within our default cute and sleek built-in template
template
should be asset- read more about assets
For gmail hosted mail:
Meteor.mail = new Meteor.Mailer
login: 'noreply-meteor'
host: 'gmail.com'
connectionUrl: "smtp://account:[email protected]:465"
accountName: "My Project MailBot"
verbose: true
intervalTime: 120
retryTimes: 10
saveHistory: true
template: 'emailTemplates/signUp.html'
For own hosted smtp server:
Meteor.mail = new Meteor.Mailer
login: '[email protected]'
host: 'smtp.example.com'
connectionUrl: "smtp://[email protected]:[email protected]:587"
accountName: "My Project MailBot"
Meteor.mail.send recipient, options, callback, sendAt, template
recipient
{String} - Recipient email addressoptions
{Object}subject
{String} - [required] Plain text or HTMLmessage
{String} - [required] Plain text or HTML with placeholderscallback
{Function} - Witherror
,success
andrecipient
parameterssendAt
{Date} - Date when email should be sent. By default current timetemplate
{String} - Path to html template, ex.:emailTemplates/reset-password.html
- if is not set, by default email will be sent within
template
passed via initialization options or our default template template
should be asset- read more about assets
Meteor.mail.send '[email protected]',
message: "Some HTML or plain-text string (required)"
subject: "Some HTML or plain-text string (required)"
#Any optional keys, like
appname: "Your application name"
url: "http://localhost:3000"
lang: 'en'
,
(error, success, recipient) ->
console.log("mail is not sent to #{recipient}") if error
console.log("mail successfully sent to #{recipient}") if success
<html lang="{{lang}}">
<head>
...
<title>{{Subject}}</title>
</head>
<body>
<h3>{{{Subject}}}</h3>
<p>{{{Message}}}</p>
<footer>
<a href="{{url}}">{{appname}}</a>
</footer>
</body>
</html>