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 optionsoptions {Object} - Object with next properties:
login{String} - [required] Your login on SMTP server, ex.:no-replyhost{String} - [required] Domain name or IP-address of SMTP server, ex.:smtp.example.comconnectionUrl{String} - [required] Connection (auth) URL with login, password and port, ex.:smtp://account:password@smtp.gmail.com:465accountName{String} - Name of the account (usually shown next to or instead of email address). By default equals tologinproperty, ex.:Some Service Name SupportintervalTime{Number} - How often try to send an email in seconds. By default60seconds, ex.:600retryTimes{Number} - How many times to retry to send email. By default50, ex.:10saveHistory{Boolean} - Save sent emails. By defaultfalse, ex.:trueverbose{Boolean} - Show messages of sending/pending into server's console. By defaultfalse, ex.:truetemplate{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
templateshould be asset- read more about assets
For gmail hosted mail:
Meteor.mail = new Meteor.Mailer
login: 'noreply-meteor'
host: 'gmail.com'
connectionUrl: "smtp://account:password@smtp.gmail.com: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: 'no-reply@example.com'
host: 'smtp.example.com'
connectionUrl: "smtp://no-reply@example.com:password@smtp.example.com:587"
accountName: "My Project MailBot"Meteor.mail.send recipient, options, callback, sendAt, templaterecipient{String} - Recipient email addressoptions{Object}subject{String} - [required] Plain text or HTMLmessage{String} - [required] Plain text or HTML with placeholderscallback{Function} - Witherror,successandrecipientparameterssendAt{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
templatepassed via initialization options or our default template templateshould be asset- read more about assets
Meteor.mail.send 'to@example.com',
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>