Skip to content

Commit

Permalink
Add remove_msgid option to outbound (haraka#2209)
Browse files Browse the repository at this point in the history
* All remove_msgid option to outbound
* Add remove_date option
* convert URL to hyperlink
* assure options is defined, simply 4x tests after
  • Loading branch information
smfreegard authored and msimerson committed Nov 10, 2017
1 parent 4a463d8 commit 8dc20c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -63,6 +63,7 @@
* timer_queue #2226
* outbound/hmail #2197
* Automatically set connection.remote.is_private when connection.remote.ip is set #2192
* Add remove_msgid and remove_date options to outbound.send_email #2209


## 2.8.16 - Sep 30, 2017
Expand Down
20 changes: 11 additions & 9 deletions docs/Outbound.md
Expand Up @@ -348,18 +348,20 @@ should queueing to disk fail e.g:

outbound.send_email(from, to, contents);

You can pass various options to `outbound.send_email` like so:

In case you are passing your content dot-stuffed (a dot at the start of a line
is doubled, like it is in SMTP conversation,
see https://tools.ietf.org/html/rfc2821#section-4.5.2), you should pass the
```dot_stuffed: true``` option, like so:

outbound.send_email(from, to, contents, outnext, { dot_stuffed: true });
outbound.send_email(from, to, contents, outnext, options);

Where `options` is a Object that may contain the following keys:

| Key/Value | Description |
|------------------------|--------------------------------------------------------------------------------------------
| `dot_stuffed: true` | Use this if you are passing your content dot-stuffed (a dot at the start of a line is doubled, like it is in SMTP conversation, see [RFC 2821](https://tools.ietf.org/html/rfc2821#section-4.5.2).|
| `notes: { key: value}` | In case you need notes in the new transaction that `send_email()` creates. |
| `remove_msgid: true` | Remove any Message-Id header found in the message. If you are reading a message in from the filesystem and you want to ensure that a generated Message-Id header is used in preference over the original. This is useful if you are releasing mail from a quarantine. |
| `remove_date: true` | Remove any Date header found in the message. If you are reading a message in from the filesystem and you want to ensure that a generated Date header is used in preference over the original. This is useful if you are releasing mail from a quarantine. |

In case you need notes in the new transaction that `send_email()` creates, you should pass the
```notes``` option, like so:

outbound.send_email(from, to, contents, outnext, { notes: transaction.notes });

[1]: `Address` objects are address-rfc2821 objects. See https://github.com/haraka/node-address-rfc2821
[1]: `Address` objects are [address-rfc2821 objects](https://github.com/haraka/node-address-rfc2821).
16 changes: 13 additions & 3 deletions outbound/index.js
Expand Up @@ -76,10 +76,10 @@ exports.send_email = function () {
let to = arguments[1];
let contents = arguments[2];
const next = arguments[3];
const options = arguments[4];
const options = arguments[4] || {};

const dot_stuffed = ((options && options.dot_stuffed) ? options.dot_stuffed : false);
const notes = ((options && options.notes) ? options.notes : null);
const dot_stuffed = options.dot_stuffed ? options.dot_stuffed : false;
const notes = options.notes ? options.notes : null;

logger.loginfo("[outbound] Sending email via params");

Expand Down Expand Up @@ -158,6 +158,16 @@ exports.send_email = function () {
}

transaction.message_stream.add_line_end();

// Allow for the removal of Message-Id and/or Date headers which
// is useful when resending mail from a quarantine.
if (options.remove_msgid) {
transaction.remove_header('Message-Id');
}
if (options.remove_date) {
transaction.remove_header('Date');
}

this.send_trans_email(transaction, next);
};

Expand Down

0 comments on commit 8dc20c0

Please sign in to comment.