First add the package : meteor add wylio:mandrill
https://atmospherejs.com/wylio/mandrill
When the application startup you need do this :
Meteor.startup(function() { return Meteor.Mandrill.config({ host: "smtp.mandrillapp.com", port: "587", username: "username@username.com.br", key: "keyMandrill" }); });
You need create a method to call : ( server side )
Meteor.methods({ sendEmail: function (from, subject, text) { check([from, subject, text], [String]); this.unblock(); Meteor.Mandrill.send({ to: "contact@contact.com", from: from, subject: subject, html: text }); } });
Example to use : ( client side )
email.html
<template name="email"> <form> <div class="form-group"> <input type="name" class="form-control" id="inputname" > </div> <div class="form-group"> <input type="email" class="form-control" id="inputemail"> </div> <div class="form-group"> <input class="form-control" id="inputphone"> </div> <textarea class="form-control" rows="3" id="inputMsg"></textarea> <button id="sendEmail" class="btn btn-default">Send</button> </form> </template>
email.js
Template.email.events({ 'click #sendEmail': function (e) { name = $('#inputname').val(); email = $('#inputemail').val(); phone = $('#inputphone').val(); msg = $('#inputMsg').val(); subject = "subject" + name; text = "Name" + name + "\n" + "Phone Number:" + phone + "\n" + "Msg:" + msg; Meteor.call('sendEmail', email, subject, text ); } });