Skip to content

Commit

Permalink
Move to emailjs repo
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhammerl committed Jan 13, 2016
1 parent 555cb9a commit 985f836
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 199 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: node_js
sudo: false
node_js:
- "0.10"
- "0.11"
- 4.1
before_install:
- npm install -g grunt-cli
notifications:
email:
- [email protected]
recipients:
- [email protected]
- [email protected]
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# mailbuild
# emailjs-mime-builder

*mailbuild* is a low level rfc2822 message composer. Define your own mime tree, no magic included.
*emailjs-mime-builder* is a low level rfc2822 message composer. Define your own mime tree, no magic included.

[![Build Status](https://travis-ci.org/whiteout-io/mailbuild.png?branch=master)](https://travis-ci.org/whiteout-io/mailbuild)
[![Build Status](https://travis-ci.org/emailjs/emailjs-mime-builder.png?branch=master)](https://travis-ci.org/emailjs/emailjs-mime-builder)

## StringEncoding API

Expand All @@ -18,18 +18,18 @@ This module requires `TextEncoder` and `TextDecoder` to exist as part of the Str

This module has dependencies that will be fetched automatically.

* [mimefuncs](https://github.com/whiteout-io/mimefuncs/)
* [mimetypes](https://github.com/whiteout-io/mimetypes/)
* [addressparser](https://github.com/whiteout-io/addressparser/)
* [emailjs-mime-codec](https://github.com/emailjs/emailjs-mime-codec/)
* [emailjs-mime-types](https://github.com/emailjs/emailjs-mime-types/)
* [emailjs-addressparser](https://github.com/emailjs/emailjs-addressparser/)
* [punycode.js](https://github.com/bestiejs/punycode.js)
* [stringencoding](https://github.com/whiteout-io/stringencoding)
* [emailjs-stringencoding](https://github.com/emailjs/emailjs-stringencoding)

## API

Create a new `Mailbuild` object with
Create a new `MimeBuilder` object with

```javascript
var builder = new Mailbuild(contentType [, options]);
var builder = new MimeBuilder(contentType [, options]);
```

Where
Expand All @@ -41,7 +41,7 @@ Where

## Methods

The same methods apply to the root node created with `new Mailbuild()` and to any child nodes.
The same methods apply to the root node created with `new MimeBuilder()` and to any child nodes.

### createChild

Expand All @@ -51,12 +51,12 @@ Creates and appends a child node to the node object
node.createChild(contentType, options)
```

The same arguments apply as with `new Mailbuild()`. Created node object is returned.
The same arguments apply as with `new MimeBuilder()`. Created node object is returned.

**Example**

```javascript
new Mailbuild("multipart/mixed").
new MimeBuilder("multipart/mixed").
createChild("multipart/related").
createChild("text/plain");
```
Expand Down Expand Up @@ -86,8 +86,8 @@ Method returns appended child node.
**Example**

```javascript
var childNode = new Mailbuild("text/plain"),
rootNode = new Mailbuild("multipart/mixed");
var childNode = new MimeBuilder("text/plain"),
rootNode = new MimeBuilder("multipart/mixed");
rootnode.appendChild(childNode);
```

Expand Down Expand Up @@ -115,9 +115,9 @@ Method returns replacement node.
**Example**

```javascript
var rootNode = new Mailbuild("multipart/mixed"),
var rootNode = new MimeBuilder("multipart/mixed"),
childNode = rootNode.createChild("text/plain");
childNode.replace(new Mailbuild("text/html"));
childNode.replace(new MimeBuilder("text/html"));
```

Generates the following mime tree:
Expand All @@ -141,7 +141,7 @@ Method returns removed node.

```javascript

var rootNode = new Mailbuild("multipart/mixed"),
var rootNode = new MimeBuilder("multipart/mixed"),
childNode = rootNode.createChild("text/plain");
childNode.remove();
```
Expand Down Expand Up @@ -173,7 +173,7 @@ Method returns current node.
**Example**

```javascript
new Mailbuild("text/plain").
new MimeBuilder("text/plain").
setHeader("content-disposition", "inline").
setHeader({
"content-transfer-encoding": "7bit"
Expand Down Expand Up @@ -214,7 +214,7 @@ Method returns current node.
**Example**

```javascript
new Mailbuild("text/plain").
new MimeBuilder("text/plain").
addHeader("X-Spam", "1").
setHeader({
"x-spam": "2"
Expand Down Expand Up @@ -248,7 +248,7 @@ Where
**Example**

```javascript
new Mailbuild("text/plain").getHeader("content-type"); // text/plain
new MimeBuilder("text/plain").getHeader("content-type"); // text/plain
```

## setContent
Expand All @@ -267,7 +267,7 @@ Where
**Example**

```javascript
new Mailbuild("text/plain").setContent("Hello world!");
new MimeBuilder("text/plain").setContent("Hello world!");
```

## build
Expand All @@ -283,7 +283,7 @@ Method returns the rfc2822 message as a string
**Example**

```javascript
new Mailbuild("text/plain").setContent("Hello world!").build();
new MimeBuilder("text/plain").setContent("Hello world!").build();
```

Returns the following string:
Expand All @@ -310,7 +310,7 @@ Method returns the envelope in the form of `{from:'address', to: ['addresses']}`
**Example**

```javascript
new Mailbuild().
new MimeBuilder().
addHeader({
from: "From <[email protected]>",
to: "[email protected]",
Expand Down Expand Up @@ -340,7 +340,7 @@ the addresses are converted to punycode automatically.
For attachments you should minimally set `filename` option and `Content-Disposition` header. If filename is specified, you can leave content type blank - if content type is not set, it is detected from the filename.

```javascript
new Mailbuild("multipart/mixed").
new MimeBuilder("multipart/mixed").
createChild(false, {filename: "image.png"}).
setHeader("Content-Disposition", "attachment");
```
Expand Down
14 changes: 0 additions & 14 deletions example/index.html

This file was deleted.

36 changes: 0 additions & 36 deletions example/index.js

This file was deleted.

74 changes: 37 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"name": "mailbuild",
"version": "0.3.7",
"homepage": "https://github.com/whiteout-io/mailbuild",
"description": "mailbuild is a low level rfc2822 message composer. Define your own mime tree, no magic included.",
"author": "Andris Reinman <[email protected]>",
"keywords": [
"RFC2822",
"mime"
],
"license": "MIT",
"scripts": {
"test": "grunt"
},
"repository": {
"type": "git",
"url": "git://github.com/whiteout-io/mailbuild.git"
},
"main": "src/mailbuild",
"dependencies": {
"mimefuncs": "~0.3.5",
"mimetypes": "~0.1.1",
"wo-addressparser": "~0.1.3",
"punycode": "~1.2.4"
},
"devDependencies": {
"chai": "~1.8.1",
"grunt": "~0.4.1",
"grunt-mocha-phantomjs": "~0.4.0",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-jshint": "~0.8.0",
"grunt-mocha-test": "~0.10.0",
"mocha": "~1.16.2",
"phantomjs": "~1.9.7-1",
"requirejs": "~2.1.10",
"sinon": "^1.9.0",
"amdefine": "^0.1.0"
}
"name": "emailjs-mime-builder",
"version": "1.0.0",
"homepage": "https://github.com/emailjs/emailjs-mime-builder",
"description": "emailjs-mime-builder is a low level rfc2822 message composer. Define your own mime tree, no magic included.",
"author": "Andris Reinman <[email protected]>",
"keywords": [
"RFC2822",
"mime"
],
"license": "MIT",
"scripts": {
"test": "grunt"
},
"repository": {
"type": "git",
"url": "git://github.com/emailjs/emailjs-mime-builder.git"
},
"main": "src/emailjs-mime-builder",
"dependencies": {
"emailjs-addressparser": "^1.0.1",
"emailjs-mime-codec": "^1.0.1",
"emailjs-mime-types": "^1.0.0",
"punycode": "^1.4.0"
},
"devDependencies": {
"amdefine": "^1.0.0",
"chai": "^3.4.1",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-jshint": "^0.11.3",
"grunt-mocha-phantomjs": "^2.0.1",
"grunt-mocha-test": "^0.12.7",
"mocha": "^2.3.4",
"phantomjs": "^1.9.19",
"requirejs": "^2.1.22",
"sinon": "^1.17.2"
}
}
28 changes: 14 additions & 14 deletions src/mailbuild.js → src/emailjs-mime-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
'use strict';

if (typeof define === 'function' && define.amd) {
define(['mimefuncs', 'mimetypes', 'punycode', 'addressparser'], factory);
define(['emailjs-mime-codec', 'emailjs-mime-types', 'punycode', 'emailjs-addressparser'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('mimefuncs'), require('mimetypes'), require('punycode'), require('wo-addressparser'));
module.exports = factory(require('emailjs-mime-codec'), require('emailjs-mime-types'), require('punycode'), require('emailjs-addressparser'));
} else {
root.mailbuild = factory(root.mimefuncs, root.mimetypes, root.punycode, root.addressparser);
root['emailjs-mime-builder'] = factory(root['emailjs-mime-codec'], root['emailjs-mime-types'], root.punycode, root['emailjs-addressparser']);
}
}(this, function(mimefuncs, mimetypes, punycode, addressparser) {
}(this, function(mimecodec, mimetypes, punycode, addressparser) {
'use strict';

/**
Expand Down Expand Up @@ -372,14 +372,14 @@

switch (header.key) {
case 'Content-Disposition':
structured = mimefuncs.parseHeaderValue(value);
structured = mimecodec.parseHeaderValue(value);
if (this.filename) {
structured.params.filename = this.filename;
}
value = this._buildHeaderValue(structured);
break;
case 'Content-Type':
structured = mimefuncs.parseHeaderValue(value);
structured = mimecodec.parseHeaderValue(value);

this._handleContentType(structured);

Expand Down Expand Up @@ -407,7 +407,7 @@
return;
}

lines.push(mimefuncs.foldLines(key + ': ' + value, 76));
lines.push(mimecodec.foldLines(key + ': ' + value, 76));
}.bind(this));

// Ensure mandatory header fields
Expand Down Expand Up @@ -440,14 +440,14 @@

switch (transferEncoding) {
case 'quoted-printable':
lines.push(mimefuncs.quotedPrintableEncode(this.content));
lines.push(mimecodec.quotedPrintableEncode(this.content));
break;
case 'base64':
lines.push(mimefuncs.base64Encode(this.content, typeof this.content === 'object' && 'binary' || false));
lines.push(mimecodec.base64Encode(this.content, typeof this.content === 'object' && 'binary' || false));
break;
default:
if (flowed) {
lines.push(mimefuncs.foldLines(this.content.replace(/\r?\n/g, '\r\n').
lines.push(mimecodec.foldLines(this.content.replace(/\r?\n/g, '\r\n').
// space stuffing http://tools.ietf.org/html/rfc3676#section-4.2
replace(/^( |From|>)/igm, ' $1'),
76, true));
Expand Down Expand Up @@ -544,7 +544,7 @@
Object.keys(structured.params || {}).forEach(function(param) {
// filename might include unicode characters so it is a special case
if (param === 'filename') {
mimefuncs.continuationEncode(param, structured.params[param], 50).forEach(function(encodedParam) {
mimecodec.continuationEncode(param, structured.params[param], 50).forEach(function(encodedParam) {
// continuation encoded strings are always escaped, so no need to use enclosing quotes
// in fact using quotes might end up with invalid filenames in some clients
paramsArray.push(encodedParam.key + '=' + encodedParam.value);
Expand Down Expand Up @@ -654,7 +654,7 @@
default:
value = (value || '').toString().replace(/\r?\n|\r/g, ' ');
// mimeWordsEncode only encodes if needed, otherwise the original string is returned
return mimefuncs.mimeWordsEncode(value, 'Q', 52);
return mimecodec.mimeWordsEncode(value, 'Q', 52);
}
};

Expand All @@ -673,7 +673,7 @@
[].concat(addresses || []).forEach(function(address) {
if (address.address) {
address.address = address.address.replace(/^.*?(?=\@)/, function(user) {
return mimefuncs.mimeWordsEncode(user, 'Q', 52);
return mimecodec.mimeWordsEncode(user, 'Q', 52);
}).replace(/@.+$/, function(domain) {
return '@' + punycode.toASCII(domain.substr(1));
});
Expand Down Expand Up @@ -706,7 +706,7 @@
if (/^[\x20-\x7e]*$/.test(name)) {
return '"' + name.replace(/([\\"])/g, '\\$1') + '"';
} else {
return mimefuncs.mimeWordEncode(name, 'Q', 52);
return mimecodec.mimeWordEncode(name, 'Q', 52);
}
}
return name;
Expand Down
Loading

0 comments on commit 985f836

Please sign in to comment.