Some mails are not moved to the right inboxes
I have an application that runs 9 mail listeners using node-imap. When a new mail arrives to one of the mails, I move it to the right box according to its title and content. The problem is that not all of the mails are moved correctly. I'll explain more after the code:
function sortEmails (imap, box) {
let emails = ;
let lead;
let site, date;
if (box.messages.total) {
// fetch all of the current inbox's mails
var imapFetch = imap.seq.fetch(`1:${box.messages.total}`, {
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)', 'TEXT'] // Get headers, body and struct
});
// For each message get the data
imapFetch.on('message', function(msg) {
msg.on('body', function(stream, info) {
stream.setEncoding('utf8');
var buffer = '';
stream.on('data', function(chunk) {
buffer += chunk.toString('utf8');
});
// Once done, check if lead or not, and act accordingly.
stream.once('end', function() {
// If header
if (info.which !== 'TEXT') {
let header = Imap.parseHeader(buffer);
// If lead, set date & site of lead.
if (header.subject[0] === 'Lead') {
site = header.from[0].slice(header.from[0].indexOf("@") + 1, -1);
date = header.date[0];
};
// If body
} else {
// if lead (spam leads included) and not regular mail.
if (site && date) {
body = parseMailBody(buffer);
// Create a new lead
lead = new Lead(body.name, body.email, body.phone, date, site, body.url, body.ip);
if (lead.isRealLead()) {
emails.push(lead);
} else {
lead = 'spam';
}
}
}
});
});
msg.once('attributes', function(attrs) {
if (!lead) {
imap.move(attrs.uid, imap.boxes.all, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else if (lead === 'spam') {
imap.move(attrs.uid, imap.boxes.spamLeads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else {
imap.move(attrs.uid, imap.boxes.leads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
}
});
});
imapFetch.once('error', function(err) {
logger.log('error', 'Mail Listeners', 'Fetch error: ' + err);
});
imapFetch.once('end', function() {
if (emails.length !== 0) {
sendBotMessage(`A new lead has just arrived.`);
sendToDB(emails);
}
});
}
}
Basically, if a mail doesn't have the title 'Lead' it will be moved to the 'ALL' directory. In addition, mails that do have the 'Lead' title and contain only English chars will be marked as spam.
The problem is, some of the mails which are leads (contain the 'Lead' title and names are not in english) are moved to the 'ALL' folder, indicating the (!lead) is true.
The mails are received from a CF7 form in Wordpress. This is a MIME of a mail that wasn't moved correctly:
Return-Path: <my@host.co.il>
Delivered-To: my@mail.co.il
Received: from s-inbox.upress.io
by s-inbox.upress.io with LMTP
id OKTqFcSEIFzwBwAAmWbRAw
(envelope-from <my@host.co.il>)
for <my@mail.co.il>; Mon, 24 Dec 2018 09:03:32 +0200
Return-path: <my@host.co.il>
Envelope-to: my@mail.co.il
Delivery-date: Mon, 24 Dec 2018 09:03:32 +0200
Received: from my@host.co.il ([myip])
by s-inbox.upress.io with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
(Exim 4.90_1)
(envelope-from <my@host.co.il>)
id 1gbKGy-0000tR-6i
for my@mail.co.il; Mon, 24 Dec 2018 09:03:32 +0200
Received: from hostname by my@host.co.il with local (Exim 4.87)
(envelope-from <my@host.co.il>)
id 1gbKGw-0000Lk-Oz
for my@mail.co.il; Mon, 24 Dec 2018 09:03:30 +0200
To: my@mail.co.il
Subject: Lead
X-PHP-Originating-Script: 1029:class-phpmailer.php
Date: Mon, 24 Dec 2018 07:03:30 +0000
From: WordPress <admin@domain.co.il>
Reply-To: test@gmail.com
Message-ID: <7b2769f42336ec7bf49edce68de30074@domain.co.il>
X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sender: <my@host.co.il>
SPFCheck: Server passes SPF test, -30 Spam score
Forward-Confirmed-ReverseDNS: Reverse and forward lookup success on 185.217.97.242, -10 Spam score
SpamTally: Final spam score: -40
name: בדיקה
mail: test@gmail.com
phone: 0435599539
ip: 84.108.61.243
url: https://myurl.co.il/
I am kind of new to the concept of streams in general and imap in particular, and I can't seem to figure out what's the problem here.
Thank you for your reading time.
node.js email imap
|
show 9 more comments
I have an application that runs 9 mail listeners using node-imap. When a new mail arrives to one of the mails, I move it to the right box according to its title and content. The problem is that not all of the mails are moved correctly. I'll explain more after the code:
function sortEmails (imap, box) {
let emails = ;
let lead;
let site, date;
if (box.messages.total) {
// fetch all of the current inbox's mails
var imapFetch = imap.seq.fetch(`1:${box.messages.total}`, {
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)', 'TEXT'] // Get headers, body and struct
});
// For each message get the data
imapFetch.on('message', function(msg) {
msg.on('body', function(stream, info) {
stream.setEncoding('utf8');
var buffer = '';
stream.on('data', function(chunk) {
buffer += chunk.toString('utf8');
});
// Once done, check if lead or not, and act accordingly.
stream.once('end', function() {
// If header
if (info.which !== 'TEXT') {
let header = Imap.parseHeader(buffer);
// If lead, set date & site of lead.
if (header.subject[0] === 'Lead') {
site = header.from[0].slice(header.from[0].indexOf("@") + 1, -1);
date = header.date[0];
};
// If body
} else {
// if lead (spam leads included) and not regular mail.
if (site && date) {
body = parseMailBody(buffer);
// Create a new lead
lead = new Lead(body.name, body.email, body.phone, date, site, body.url, body.ip);
if (lead.isRealLead()) {
emails.push(lead);
} else {
lead = 'spam';
}
}
}
});
});
msg.once('attributes', function(attrs) {
if (!lead) {
imap.move(attrs.uid, imap.boxes.all, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else if (lead === 'spam') {
imap.move(attrs.uid, imap.boxes.spamLeads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else {
imap.move(attrs.uid, imap.boxes.leads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
}
});
});
imapFetch.once('error', function(err) {
logger.log('error', 'Mail Listeners', 'Fetch error: ' + err);
});
imapFetch.once('end', function() {
if (emails.length !== 0) {
sendBotMessage(`A new lead has just arrived.`);
sendToDB(emails);
}
});
}
}
Basically, if a mail doesn't have the title 'Lead' it will be moved to the 'ALL' directory. In addition, mails that do have the 'Lead' title and contain only English chars will be marked as spam.
The problem is, some of the mails which are leads (contain the 'Lead' title and names are not in english) are moved to the 'ALL' folder, indicating the (!lead) is true.
The mails are received from a CF7 form in Wordpress. This is a MIME of a mail that wasn't moved correctly:
Return-Path: <my@host.co.il>
Delivered-To: my@mail.co.il
Received: from s-inbox.upress.io
by s-inbox.upress.io with LMTP
id OKTqFcSEIFzwBwAAmWbRAw
(envelope-from <my@host.co.il>)
for <my@mail.co.il>; Mon, 24 Dec 2018 09:03:32 +0200
Return-path: <my@host.co.il>
Envelope-to: my@mail.co.il
Delivery-date: Mon, 24 Dec 2018 09:03:32 +0200
Received: from my@host.co.il ([myip])
by s-inbox.upress.io with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
(Exim 4.90_1)
(envelope-from <my@host.co.il>)
id 1gbKGy-0000tR-6i
for my@mail.co.il; Mon, 24 Dec 2018 09:03:32 +0200
Received: from hostname by my@host.co.il with local (Exim 4.87)
(envelope-from <my@host.co.il>)
id 1gbKGw-0000Lk-Oz
for my@mail.co.il; Mon, 24 Dec 2018 09:03:30 +0200
To: my@mail.co.il
Subject: Lead
X-PHP-Originating-Script: 1029:class-phpmailer.php
Date: Mon, 24 Dec 2018 07:03:30 +0000
From: WordPress <admin@domain.co.il>
Reply-To: test@gmail.com
Message-ID: <7b2769f42336ec7bf49edce68de30074@domain.co.il>
X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sender: <my@host.co.il>
SPFCheck: Server passes SPF test, -30 Spam score
Forward-Confirmed-ReverseDNS: Reverse and forward lookup success on 185.217.97.242, -10 Spam score
SpamTally: Final spam score: -40
name: בדיקה
mail: test@gmail.com
phone: 0435599539
ip: 84.108.61.243
url: https://myurl.co.il/
I am kind of new to the concept of streams in general and imap in particular, and I can't seem to figure out what's the problem here.
Thank you for your reading time.
node.js email imap
I'm not familiar with node but it looks like you have hard-coded some assumptions about MIME structure and message encoding which may not hold for all messages. What is the MIME type of the failed messages and are they encoded as you expect?
– tripleee
Jan 3 at 7:56
Can you please point me to the part of the code you're talking about? Some part of the code is taken from the node imap package page. Also, how can I check the MIME type of the failed messages? @tripleee
– Sagi Rika
Jan 3 at 7:59
Including the source of one of the messages would perhaps be helpful, though if they are bulky, reduce it to just the headers and some placeholder text. I'm looking at the utf-8 assumption in particular. I'm not sure what sort of normalizationparseMailBody
does but if you feed it incorrectly decoded data, I imagine you could easily end up with garbage output.
– tripleee
Jan 3 at 8:04
I added the source of the emails andparseMailBody
so you can have a look :) @tripleee
– Sagi Rika
Jan 3 at 8:09
That's not email source, those are some random contents from one body part. The MIME structure looks something like this (random find from Pastebin by googling): pastebin.com/0CZ5iqyG
– tripleee
Jan 3 at 8:10
|
show 9 more comments
I have an application that runs 9 mail listeners using node-imap. When a new mail arrives to one of the mails, I move it to the right box according to its title and content. The problem is that not all of the mails are moved correctly. I'll explain more after the code:
function sortEmails (imap, box) {
let emails = ;
let lead;
let site, date;
if (box.messages.total) {
// fetch all of the current inbox's mails
var imapFetch = imap.seq.fetch(`1:${box.messages.total}`, {
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)', 'TEXT'] // Get headers, body and struct
});
// For each message get the data
imapFetch.on('message', function(msg) {
msg.on('body', function(stream, info) {
stream.setEncoding('utf8');
var buffer = '';
stream.on('data', function(chunk) {
buffer += chunk.toString('utf8');
});
// Once done, check if lead or not, and act accordingly.
stream.once('end', function() {
// If header
if (info.which !== 'TEXT') {
let header = Imap.parseHeader(buffer);
// If lead, set date & site of lead.
if (header.subject[0] === 'Lead') {
site = header.from[0].slice(header.from[0].indexOf("@") + 1, -1);
date = header.date[0];
};
// If body
} else {
// if lead (spam leads included) and not regular mail.
if (site && date) {
body = parseMailBody(buffer);
// Create a new lead
lead = new Lead(body.name, body.email, body.phone, date, site, body.url, body.ip);
if (lead.isRealLead()) {
emails.push(lead);
} else {
lead = 'spam';
}
}
}
});
});
msg.once('attributes', function(attrs) {
if (!lead) {
imap.move(attrs.uid, imap.boxes.all, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else if (lead === 'spam') {
imap.move(attrs.uid, imap.boxes.spamLeads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else {
imap.move(attrs.uid, imap.boxes.leads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
}
});
});
imapFetch.once('error', function(err) {
logger.log('error', 'Mail Listeners', 'Fetch error: ' + err);
});
imapFetch.once('end', function() {
if (emails.length !== 0) {
sendBotMessage(`A new lead has just arrived.`);
sendToDB(emails);
}
});
}
}
Basically, if a mail doesn't have the title 'Lead' it will be moved to the 'ALL' directory. In addition, mails that do have the 'Lead' title and contain only English chars will be marked as spam.
The problem is, some of the mails which are leads (contain the 'Lead' title and names are not in english) are moved to the 'ALL' folder, indicating the (!lead) is true.
The mails are received from a CF7 form in Wordpress. This is a MIME of a mail that wasn't moved correctly:
Return-Path: <my@host.co.il>
Delivered-To: my@mail.co.il
Received: from s-inbox.upress.io
by s-inbox.upress.io with LMTP
id OKTqFcSEIFzwBwAAmWbRAw
(envelope-from <my@host.co.il>)
for <my@mail.co.il>; Mon, 24 Dec 2018 09:03:32 +0200
Return-path: <my@host.co.il>
Envelope-to: my@mail.co.il
Delivery-date: Mon, 24 Dec 2018 09:03:32 +0200
Received: from my@host.co.il ([myip])
by s-inbox.upress.io with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
(Exim 4.90_1)
(envelope-from <my@host.co.il>)
id 1gbKGy-0000tR-6i
for my@mail.co.il; Mon, 24 Dec 2018 09:03:32 +0200
Received: from hostname by my@host.co.il with local (Exim 4.87)
(envelope-from <my@host.co.il>)
id 1gbKGw-0000Lk-Oz
for my@mail.co.il; Mon, 24 Dec 2018 09:03:30 +0200
To: my@mail.co.il
Subject: Lead
X-PHP-Originating-Script: 1029:class-phpmailer.php
Date: Mon, 24 Dec 2018 07:03:30 +0000
From: WordPress <admin@domain.co.il>
Reply-To: test@gmail.com
Message-ID: <7b2769f42336ec7bf49edce68de30074@domain.co.il>
X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sender: <my@host.co.il>
SPFCheck: Server passes SPF test, -30 Spam score
Forward-Confirmed-ReverseDNS: Reverse and forward lookup success on 185.217.97.242, -10 Spam score
SpamTally: Final spam score: -40
name: בדיקה
mail: test@gmail.com
phone: 0435599539
ip: 84.108.61.243
url: https://myurl.co.il/
I am kind of new to the concept of streams in general and imap in particular, and I can't seem to figure out what's the problem here.
Thank you for your reading time.
node.js email imap
I have an application that runs 9 mail listeners using node-imap. When a new mail arrives to one of the mails, I move it to the right box according to its title and content. The problem is that not all of the mails are moved correctly. I'll explain more after the code:
function sortEmails (imap, box) {
let emails = ;
let lead;
let site, date;
if (box.messages.total) {
// fetch all of the current inbox's mails
var imapFetch = imap.seq.fetch(`1:${box.messages.total}`, {
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)', 'TEXT'] // Get headers, body and struct
});
// For each message get the data
imapFetch.on('message', function(msg) {
msg.on('body', function(stream, info) {
stream.setEncoding('utf8');
var buffer = '';
stream.on('data', function(chunk) {
buffer += chunk.toString('utf8');
});
// Once done, check if lead or not, and act accordingly.
stream.once('end', function() {
// If header
if (info.which !== 'TEXT') {
let header = Imap.parseHeader(buffer);
// If lead, set date & site of lead.
if (header.subject[0] === 'Lead') {
site = header.from[0].slice(header.from[0].indexOf("@") + 1, -1);
date = header.date[0];
};
// If body
} else {
// if lead (spam leads included) and not regular mail.
if (site && date) {
body = parseMailBody(buffer);
// Create a new lead
lead = new Lead(body.name, body.email, body.phone, date, site, body.url, body.ip);
if (lead.isRealLead()) {
emails.push(lead);
} else {
lead = 'spam';
}
}
}
});
});
msg.once('attributes', function(attrs) {
if (!lead) {
imap.move(attrs.uid, imap.boxes.all, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else if (lead === 'spam') {
imap.move(attrs.uid, imap.boxes.spamLeads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
} else {
imap.move(attrs.uid, imap.boxes.leads, function(err) {
if (err) {
logger.log('error', 'Mail Listeners', 'Move error: ' + err);
}
});
}
});
});
imapFetch.once('error', function(err) {
logger.log('error', 'Mail Listeners', 'Fetch error: ' + err);
});
imapFetch.once('end', function() {
if (emails.length !== 0) {
sendBotMessage(`A new lead has just arrived.`);
sendToDB(emails);
}
});
}
}
Basically, if a mail doesn't have the title 'Lead' it will be moved to the 'ALL' directory. In addition, mails that do have the 'Lead' title and contain only English chars will be marked as spam.
The problem is, some of the mails which are leads (contain the 'Lead' title and names are not in english) are moved to the 'ALL' folder, indicating the (!lead) is true.
The mails are received from a CF7 form in Wordpress. This is a MIME of a mail that wasn't moved correctly:
Return-Path: <my@host.co.il>
Delivered-To: my@mail.co.il
Received: from s-inbox.upress.io
by s-inbox.upress.io with LMTP
id OKTqFcSEIFzwBwAAmWbRAw
(envelope-from <my@host.co.il>)
for <my@mail.co.il>; Mon, 24 Dec 2018 09:03:32 +0200
Return-path: <my@host.co.il>
Envelope-to: my@mail.co.il
Delivery-date: Mon, 24 Dec 2018 09:03:32 +0200
Received: from my@host.co.il ([myip])
by s-inbox.upress.io with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
(Exim 4.90_1)
(envelope-from <my@host.co.il>)
id 1gbKGy-0000tR-6i
for my@mail.co.il; Mon, 24 Dec 2018 09:03:32 +0200
Received: from hostname by my@host.co.il with local (Exim 4.87)
(envelope-from <my@host.co.il>)
id 1gbKGw-0000Lk-Oz
for my@mail.co.il; Mon, 24 Dec 2018 09:03:30 +0200
To: my@mail.co.il
Subject: Lead
X-PHP-Originating-Script: 1029:class-phpmailer.php
Date: Mon, 24 Dec 2018 07:03:30 +0000
From: WordPress <admin@domain.co.il>
Reply-To: test@gmail.com
Message-ID: <7b2769f42336ec7bf49edce68de30074@domain.co.il>
X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sender: <my@host.co.il>
SPFCheck: Server passes SPF test, -30 Spam score
Forward-Confirmed-ReverseDNS: Reverse and forward lookup success on 185.217.97.242, -10 Spam score
SpamTally: Final spam score: -40
name: בדיקה
mail: test@gmail.com
phone: 0435599539
ip: 84.108.61.243
url: https://myurl.co.il/
I am kind of new to the concept of streams in general and imap in particular, and I can't seem to figure out what's the problem here.
Thank you for your reading time.
node.js email imap
node.js email imap
edited Jan 3 at 9:34
Sagi Rika
asked Jan 3 at 7:51
Sagi RikaSagi Rika
8611
8611
I'm not familiar with node but it looks like you have hard-coded some assumptions about MIME structure and message encoding which may not hold for all messages. What is the MIME type of the failed messages and are they encoded as you expect?
– tripleee
Jan 3 at 7:56
Can you please point me to the part of the code you're talking about? Some part of the code is taken from the node imap package page. Also, how can I check the MIME type of the failed messages? @tripleee
– Sagi Rika
Jan 3 at 7:59
Including the source of one of the messages would perhaps be helpful, though if they are bulky, reduce it to just the headers and some placeholder text. I'm looking at the utf-8 assumption in particular. I'm not sure what sort of normalizationparseMailBody
does but if you feed it incorrectly decoded data, I imagine you could easily end up with garbage output.
– tripleee
Jan 3 at 8:04
I added the source of the emails andparseMailBody
so you can have a look :) @tripleee
– Sagi Rika
Jan 3 at 8:09
That's not email source, those are some random contents from one body part. The MIME structure looks something like this (random find from Pastebin by googling): pastebin.com/0CZ5iqyG
– tripleee
Jan 3 at 8:10
|
show 9 more comments
I'm not familiar with node but it looks like you have hard-coded some assumptions about MIME structure and message encoding which may not hold for all messages. What is the MIME type of the failed messages and are they encoded as you expect?
– tripleee
Jan 3 at 7:56
Can you please point me to the part of the code you're talking about? Some part of the code is taken from the node imap package page. Also, how can I check the MIME type of the failed messages? @tripleee
– Sagi Rika
Jan 3 at 7:59
Including the source of one of the messages would perhaps be helpful, though if they are bulky, reduce it to just the headers and some placeholder text. I'm looking at the utf-8 assumption in particular. I'm not sure what sort of normalizationparseMailBody
does but if you feed it incorrectly decoded data, I imagine you could easily end up with garbage output.
– tripleee
Jan 3 at 8:04
I added the source of the emails andparseMailBody
so you can have a look :) @tripleee
– Sagi Rika
Jan 3 at 8:09
That's not email source, those are some random contents from one body part. The MIME structure looks something like this (random find from Pastebin by googling): pastebin.com/0CZ5iqyG
– tripleee
Jan 3 at 8:10
I'm not familiar with node but it looks like you have hard-coded some assumptions about MIME structure and message encoding which may not hold for all messages. What is the MIME type of the failed messages and are they encoded as you expect?
– tripleee
Jan 3 at 7:56
I'm not familiar with node but it looks like you have hard-coded some assumptions about MIME structure and message encoding which may not hold for all messages. What is the MIME type of the failed messages and are they encoded as you expect?
– tripleee
Jan 3 at 7:56
Can you please point me to the part of the code you're talking about? Some part of the code is taken from the node imap package page. Also, how can I check the MIME type of the failed messages? @tripleee
– Sagi Rika
Jan 3 at 7:59
Can you please point me to the part of the code you're talking about? Some part of the code is taken from the node imap package page. Also, how can I check the MIME type of the failed messages? @tripleee
– Sagi Rika
Jan 3 at 7:59
Including the source of one of the messages would perhaps be helpful, though if they are bulky, reduce it to just the headers and some placeholder text. I'm looking at the utf-8 assumption in particular. I'm not sure what sort of normalization
parseMailBody
does but if you feed it incorrectly decoded data, I imagine you could easily end up with garbage output.– tripleee
Jan 3 at 8:04
Including the source of one of the messages would perhaps be helpful, though if they are bulky, reduce it to just the headers and some placeholder text. I'm looking at the utf-8 assumption in particular. I'm not sure what sort of normalization
parseMailBody
does but if you feed it incorrectly decoded data, I imagine you could easily end up with garbage output.– tripleee
Jan 3 at 8:04
I added the source of the emails and
parseMailBody
so you can have a look :) @tripleee– Sagi Rika
Jan 3 at 8:09
I added the source of the emails and
parseMailBody
so you can have a look :) @tripleee– Sagi Rika
Jan 3 at 8:09
That's not email source, those are some random contents from one body part. The MIME structure looks something like this (random find from Pastebin by googling): pastebin.com/0CZ5iqyG
– tripleee
Jan 3 at 8:10
That's not email source, those are some random contents from one body part. The MIME structure looks something like this (random find from Pastebin by googling): pastebin.com/0CZ5iqyG
– tripleee
Jan 3 at 8:10
|
show 9 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54018303%2fsome-mails-are-not-moved-to-the-right-inboxes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54018303%2fsome-mails-are-not-moved-to-the-right-inboxes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'm not familiar with node but it looks like you have hard-coded some assumptions about MIME structure and message encoding which may not hold for all messages. What is the MIME type of the failed messages and are they encoded as you expect?
– tripleee
Jan 3 at 7:56
Can you please point me to the part of the code you're talking about? Some part of the code is taken from the node imap package page. Also, how can I check the MIME type of the failed messages? @tripleee
– Sagi Rika
Jan 3 at 7:59
Including the source of one of the messages would perhaps be helpful, though if they are bulky, reduce it to just the headers and some placeholder text. I'm looking at the utf-8 assumption in particular. I'm not sure what sort of normalization
parseMailBody
does but if you feed it incorrectly decoded data, I imagine you could easily end up with garbage output.– tripleee
Jan 3 at 8:04
I added the source of the emails and
parseMailBody
so you can have a look :) @tripleee– Sagi Rika
Jan 3 at 8:09
That's not email source, those are some random contents from one body part. The MIME structure looks something like this (random find from Pastebin by googling): pastebin.com/0CZ5iqyG
– tripleee
Jan 3 at 8:10