- Make sure you have got email package in projectfolder/.meteor/packages file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
email - Create server side code in order to send email (Email.send can be called only on server side). That code you can call from client later on.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Meteor.methods({ sendEmail: function (userId, email) { if (this.userId == userId) { Email.send(email); } } }); - Make a template that show a link that invokes client side JavaScript that sends the email.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
<template name='welcomePage'> <a id='send-email-button'>Send email</a> </template> - Make the call from the client in order to send an email.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Template.welcomePage.events({ 'click #send-email-button': function () { var email = { to: 'xyz@failtracker.com', from: 'abc@failtracker.com', replyTo: 'abct@failtracker.com', subject: "test email", text: "hello lover boy" }; Meteor.call('sendEmail', this.userId, email); } });
Tuesday, July 30, 2013
Meteor: How to send email from client
Labels:
meteor
Subscribe to:
Post Comments (Atom)
set the MAIL_URL environment variable in server side.
ReplyDelete