Skip to content

Commit aee705a

Browse files
committed
Merge pull request haraka#1176 from msimerson/dot_stuffing_outbound_send_mail
Outbound.send_email: added dot-stuffing
2 parents 6bfd90d + 057170f commit aee705a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/Outbound.md

+7
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,10 @@ should queueing to disk fail e.g:
276276

277277
outbound.send_email(from, to, contents);
278278

279+
280+
In case you are passing your content dot-stuffed (a dot at the start of a line
281+
is doubled, like it is in SMTP conversation,
282+
see https://tools.ietf.org/html/rfc2821#section-4.5.2), you should pass the
283+
```dot_stuffed: true``` option, like so:
284+
285+
outbound.send_email(from, to, contents, outnext, { dot_stuffed: true });

outbound.js

+6
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ exports.send_email = function () {
355355
to = arguments[1],
356356
contents = arguments[2];
357357
var next = arguments[3];
358+
var options = arguments[4];
359+
360+
var dot_stuffed = ((options && options.dot_stuffed) ? options.dot_stuffed : false);
358361

359362
this.loginfo("Sending email via params");
360363

@@ -408,6 +411,9 @@ exports.send_email = function () {
408411
while (match = re.exec(contents)) {
409412
var line = match[1];
410413
line = line.replace(/\r?\n?$/, '\r\n'); // make sure it ends in \r\n
414+
if (dot_stuffed === false && line.length > 3 && line.substr(0,1) === '.') {
415+
line = "." + line;
416+
}
411417
transaction.add_data(new Buffer(line));
412418
contents = contents.substr(match[1].length);
413419
if (contents.length === 0) {

0 commit comments

Comments
 (0)