0.4.113 • Published 6 months ago

larvitammail v0.4.113

Weekly downloads
1
License
UNLICENSED
Repository
github
Last release
6 months ago

Build Status

larvitammail

Mailing framework for the Larvit AM project

Subscribing to exchanges in the RabbitMQ-network and by extensions and templates sends emails depending on rules in the extensions.

Usage

Setup

const Intercom = require('larvitamintercom'),
const AmMail = require('larvitammail'),
const Mail = require('larvitmail');

const amMail = new AmMail({
	intercom: new Intercom('amqp://user:password@192.168.0.1/'), // It is important this is a standalone intercom instance!
	mail: new Mail({
		transportConf: 'smtps://user%40gmail.com:pass@smtp.gmail.com',
		mailDefaults: {
			from: 'foo@bar.com'
		}
	}),
});

await amMail.registerSubscriptions();
// Up and running now!

Subscriptions

Now create a folder in your process.cwd() called "subscriptions". In that directory you create another folder with the same name as your exchange in you subscriptions, in this case "exampleExchange". Now create a file in that directory with the same as your action in that exchange, in this case "exampleAction.js"

And it should look something like this (subscriptions/exampleExchange/exampleAction.js):

// The value "params" here is the object that was sent in the subscriptions message.
exports = module.exports = async params => {
	return {
		// Mandatory
		to: 'bar@foo.com',

		// Optional
		subject: 'The file you wanted', // Defaults to empty string
		from: 'from@someone.com', // Defaults to mail defaults from
		templateData: {'username': 'Lennart'}, // Defaults to empty object. This is the data that will be sent to the email template.
		notSend: true, // Will make this email not being sent
		template: 'subscriptions/exampleExchange/exampleAction.tmpl',	// Defaults to the same as this file, but tmpl instead of js as file ending

		// Attachments, attached files, optional
		attachments: [
			{
				filename: 'text.txt',
				content: new Buffer('hello world!', 'utf-8')
			}
		]
	};
};

Templates

As default to our above subscription, create a file in process.cwd(): subscriptions/exampleExchange/exampleAction.tmpl

The templating is done with lodash and it should look something like this:

Hi <%= obj.username %>!
Here is the file you requested.

Best regards
Mr. Smith

Result

Now will larvitammail listen to the exchange "exampleExchange" and as soon a message with the action "exampleAction" is received the mailer will look for the subscription in "subscriptions/exampleExchane/exampleAction.js" and will return data to proceed. Then it will fetch the template in "subscriptions/exampleExchane/exampleAction.tmpl" and send the email.

0.4.109

8 months ago

0.4.108

8 months ago

0.4.107

9 months ago

0.4.99

10 months ago

0.4.113

6 months ago

0.4.112

6 months ago

0.4.111

7 months ago

0.4.110

8 months ago

0.4.102

10 months ago

0.4.101

10 months ago

0.4.100

10 months ago

0.4.106

9 months ago

0.4.105

9 months ago

0.4.104

9 months ago

0.4.103

9 months ago

0.4.98

11 months ago

0.4.97

11 months ago

0.4.95

12 months ago

0.4.96

12 months ago

0.4.93

12 months ago

0.4.94

12 months ago

0.4.91

1 year ago

0.4.92

1 year ago

0.4.90

1 year ago

0.4.86

1 year ago

0.4.87

1 year ago

0.4.84

1 year ago

0.4.85

1 year ago

0.4.82

1 year ago

0.4.83

1 year ago

0.4.80

1 year ago

0.4.81

1 year ago

0.4.88

1 year ago

0.4.89

1 year ago

0.4.79

1 year ago

0.4.78

1 year ago

0.4.77

1 year ago

0.4.76

1 year ago

0.4.75

1 year ago

0.4.74

1 year ago

0.4.73

1 year ago

0.4.72

2 years ago

0.4.71

2 years ago

0.4.70

2 years ago

0.4.69

2 years ago

0.4.68

2 years ago

0.4.67

2 years ago

0.4.66

2 years ago

0.4.65

2 years ago

0.4.64

2 years ago

0.4.63

2 years ago

0.4.62

2 years ago

0.4.61

2 years ago

0.4.60

2 years ago

0.4.53

2 years ago

0.4.54

2 years ago

0.4.52

2 years ago

0.4.59

2 years ago

0.4.57

2 years ago

0.4.58

2 years ago

0.4.55

2 years ago

0.4.56

2 years ago

0.4.51

2 years ago

0.4.42

2 years ago

0.4.43

2 years ago

0.4.48

2 years ago

0.4.49

2 years ago

0.4.46

2 years ago

0.4.47

2 years ago

0.4.44

2 years ago

0.4.45

2 years ago

0.4.50

2 years ago

0.4.40

2 years ago

0.4.41

2 years ago

0.4.39

2 years ago

0.4.38

2 years ago

0.4.31

3 years ago

0.4.32

3 years ago

0.4.30

3 years ago

0.4.37

2 years ago

0.4.35

3 years ago

0.4.36

3 years ago

0.4.33

3 years ago

0.4.34

3 years ago

0.4.20

3 years ago

0.4.21

3 years ago

0.4.28

3 years ago

0.4.29

3 years ago

0.4.26

3 years ago

0.4.27

3 years ago

0.4.24

3 years ago

0.4.25

3 years ago

0.4.22

3 years ago

0.4.23

3 years ago

0.4.19

3 years ago

0.4.17

3 years ago

0.4.18

3 years ago

0.4.15

3 years ago

0.4.16

3 years ago

0.4.14

3 years ago

0.4.10

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.4.13

3 years ago

0.4.11

3 years ago

0.4.12

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

4 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

6 years ago

0.1.1

8 years ago