Code Monkey home page Code Monkey logo

emailengine's People

Contributors

andris9 avatar clayrisser avatar edeuxk avatar em411 avatar github-actions[bot] avatar jhult avatar kusmira avatar laurentsenta avatar lievenjanssen avatar negan1911 avatar nisanthchunduru avatar voyc-jean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emailengine's Issues

How to run on a particular API version

Hi @andris9 ,

I have connected IMAP by running the command that you have given in this documentation. i.e. $ npx imapapi --dbs.redis="redis://127.0.0.1:6379"
When I restarted this command on server it's runs on the latest version v1.3.0 .
Here my concern is, I have written this code based on the current version. What if any APIs gets changes for the future versions? then, my code will break.
Is there any option to run the command $ npx imapapi --dbs.redis="redis://127.0.0.1:6379" on a particular version of IMAP? or any other way to over come the version issue?

Cannot acquire mailbox lock

Describe the bug
when trying to list messages in a mailbox through imapapi we get a 504 Gateway Time-outerror.
after checking imapapi logs it looks like the API is not able to get a lock on the target mailbox.

To Reproduce
it's quite random and not easy to reproduce

Expected behavior
be able to get lock on the mailbox

Screenshots
This is the latest message in logs (we are expecting Mailbox lock acquired after that message) :

imapapi[409381]: {"level":10,"time":1610401217568,"pid":409381,"hostname":"ip-10-0-101-148","tid":4,"component":"imap-client","account":"test","sub":"imap-connection","msg":"Requesting lock","path":"INBOX","lockId":514}

Additional context
When the problem occured I tried to execute exactly the same request for another account/mailbox and it's working.
So i guess there is an issue getting a lock on this specific account/mailbox (probably lock has not been released properly previously)

To avoid this issue, is there a way to automatically release the lock after a period of time ?

Message ID changes when e-mail is changed folder and back (Outlook)

First of all, great work on this library! We have been using it for months now and it is a crucial part of our application ecosystem.

Describe the bug
When a message on Outlook server is moved from INBOX to Archive and then back to INBOX, the 'id' is different. The webhook 'messageNew' is therefore fired again and data gets duplicated in our application.

To Reproduce
Steps to reproduce the behavior:

  1. Add an Outlook (outlook.office365.com) account to IMAPAPI (I can provide you one if you need testing)
  2. Let 'init' complete
  3. Check 'id' field of last message with /messages?path=INBOX
  4. Move e-mail in Outlook or Web Outlook to other folder, like Archive
  5. Move e-mail back to INBOX again
  6. Check message ID of the same e-mail as step 3, you will see the 'id' of message, attachments and text are changed.

Expected behavior
That the id of the same message in the same folder is always the same, and the webhook 'messageNew' therefore only fires ones.

Additional context
Looks related to #17, but it is not about Gmail, and not about reading a specific folder instead of '[Gmail]All messages'. As far as I can see there is no 'All E-mail' folder in Outlook, to prevent the different message ID's in different folders.

Possible solutions

  • The best way seems to me to keep the hashing of folder/message the same, but I don't know how that technically works.

  • I might use the "messageId" data field in the format 'HE1PR0601MB20750BBC5A1A61F13EBE5CDFC76F9@HE1PR0601MB2075.eurprd06.prod.outlook.com', but then we will need to setup a separate database to remember which id's are already processed or not and check them on incoming webhooks. I am not sure these are always unique though.

OFFICE365 - cannot download message by messsage_id

Version 1.4.6
After full sync of all emails from OFFICE365 I cannot download message by endpoint "/v1/account/{account}/message/{message_id}".

If I search mailbox (by IMAPAPI ) there is message with text.id: "AAAAAgAAJYCTkaExkaEykA" and uid: "9600".
GET "/v1/account/{account}/message/AAAAAgAAJYCTkaExkaEykA" returns "Requested message was not found".
After adding more logs I found that in file lib/mailbox.js in function "getMessage(message, options)" line imapClient.fetchOne(message.uid, fields, { uid: true }) returns false - messageData is set to false.

Could you help me with this ?

Use of Redis server as a dependency

Hi @andris9 ,

Is redis is using to process the webhooks notifications in queue process?
what happens if we don't remove the unhandled requests which are already present in the redis. How do we remove those(Unhandled or processed requests) requests from redis?

Thanks in advance.

[Severe bug]: POST API: ​/v1​/account​/{account}​/search does not give proper search result for the domain

Hi @andris9 ,
When I call a post api ​/v1​/account​/{account}​/search with filters like:
{ "search":{ "from:"@pippintechnologies.com" } }
The resulted filter mails not only contains the mail received from domain @pippintechnologies.com, other domain mails like @gmail.com will also be including,
please look for the below screenshot for reference:
image

Any help on this will surely helps us!
Thanks.

Account filters

Is your feature request related to a problem? Please describe.
We are using a catch-all gmail account (Delivered-To != To) and triggering webhooks for all incoming emails would be too much. There is only one imap account for multiple mail-aliases.

Describe the solution you'd like
I would like to specify a filter when creating an account to only retrieve mails with a To-Header matching a string or maybe even a regex pattern. Maybe it would also make sense to filter additional headers.

Describe alternatives you've considered
Alternative would be a possibility to create webhooks for specific mailboxes.

Thank you for your great work!

Moving messages around ?

Hi,

What should we expect when an email is moved between two folders on the same account ? Is there a way to track this message by an ID?

Follow up on question, let's say a user have two IMAP inboxes in his email client and he drags an email from Account 1/INBOX to Account 2 / Archives

Is there a way to track that this is the same email being moved around ?

what kind of events should we expect from imapapi?

Thanks!

Can we able to get webhooks events for only incoming messages.

Hi @andris9 ,

Now in my application Iam getting the all events through webhooks like "messageNew", "messageUpdated" and "messageDeleted" etc. Is it possible to get only specific events like "messageNew"?. So I can minimize the unnecessary webhooks triggers call which I don't want in my web application.
Please reply me.

Thanks in advance.

Production mode

Hi @andris9

Quick one. Would it be possible to add in some production mode or some basic auth on the dashboard for when this is used in a live environment?

Currently the way I understand it, once you start the server you can just access it directly, giving you access to the settings where you can view (or change if you are being malicious) the webhook, and also the swagger docs which basically gives you root access to all mailboxes as you can query them and read all mail contents.

Right now the only way I can think of deploying it to live is to set up an instance on aws where the imap-api server will run, and then lock that down as much as possible to only be accessible by a specific server that needs to do api calls to it. And as I would need to see the interface for some scenarios, I would need to whitelist an ip or two to be able to access the dashboard.

Am I maybe understanding things wrong and there is a diff approach for going to live? It would be nice if there was an option to place the dashboard behind some basic auth, or disable swagger docs for live or something along those lines?

Any thoughts on this?

submit a simple email make 500 error

Describe the bug
A clear and concise description of what the bug is.
on swagger ui, submit a new email with basic things returns a 500

To Reproduce
Steps to reproduce the behavior:
{

"from":
{
"name": "From Me",
"address": "[email protected]"
}
,
"to": [
{
"address": "[email protected]"
}
],

"subject": "What a wonderful message",
"text": "Hello from myself!"
}

Expected behavior
Send a mail

Screenshots

Desktop (please complete the following information):

  • OS: Mac Os
  • Browser chrome
  • Version master

Additional context
Maybe a bug,the from on swagger appear as array and I think need to be a object (as api respone say)

IMAP API is unable to connect to Office365's IMAP server

Hi @andris9,

IMAP API is unable to connect to Office365's IMAP server.

When I add a outlook.com email address to IMAP API

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'localhost:13000/v1/accounts',
  'headers': {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"account":"[email protected]","name":"[email protected]","imap":{"host":"outlook.office365.com","port":993,"secure":true,"useAuthServer":true},"smtp":{"host":"smtp.office365.com","port":587,"secure":true,"useAuthServer":true}})

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});

IMAP API was unable to authenticate because it couldn't find a supported authentication mechanism

2020-05-02 at 2 12 PM

Outlook's IMAP server only has the AUTH=PLAIN and the AUTH=XOAUTH2 capabilities

require "net/imap"
imap = Net::IMAP.new('outlook.office365.com', 993, usessl = true, certs = nil, verify = false)
imap.capability

I opened a pull request that adds support for the XOAUTH2 authentication mechanism to imapflow
postalsys/imapflow#17

Would you like to merge my change?

Thanks for your time.

The response to get the attachment is not in the stream format

Hi @andris9 ,

When I make a API call to get the attachments to the uri: 'http://127.0.0.1:3000/v1/account/' + accountId + '/attachment/' + attachmentId, , the response I get is not the file stream, to write the stream into the PDF file in my application.
What format we do get as response for the different file types like PDF, word or text files?

Thanks in advance.

How to run in different port instead of 3000 or run multiple instance

Is your feature request related to a problem? Please describe.
I want to run 2 or more instance in same server however its service only with port 3000

Describe the solution you'd like
I think we should have full control instead of hard-coded port setting using command line or config file.

Describe alternatives you've considered
I tried to find the port code on node modules but unable to find it but in repository we can see that config.

Any help on this will surely help us

Thanks

Search by bcc not working

Problem
Searching emails by bcc always returns an empty result.

To Reproduce
Send an email to some imap inbox using bcc, for example
date | mail -s test [email protected] -a "bcc: [email protected]"
Access the IMAP inbox with the imapi and use a bcc search filter on POST <account>/search?path=INBOX

{
  "search": {
    "bcc": "[email protected]"
  }
}

You won't find the email.

Expected behavior
All emails having the address in the bcc header are in the result set.

General Question about amount of mailboxes

Hi @andris9

As the author of the software, would you say there is any hard limit on how many mailboxes can be connected at once? What are the gotcha's someone should be looking out for? Does more mailboxes = possible longer time between getting notifications?

We are investigating an alternative approach to syncing mailboxes, currently we poll mailboxes every one or two minutes, but it's a bit intensive on the client imap servers. We have about 600 mailboxes that we sync this way.

Adding 600 to just one instance of imap-api doesn't seem feasible, although I could be wrong, hence my question today :)

Thanks for creating this package, you've really found a nice and clean solution to handling incoming mail in an application. It's working nicely with my tests so far (except some outlook scenarios. With mail it never seems like a one golden solution, always something with some mail provider)

notifyFrom is not working

notifyFrom field is not working, i wanted to synchronize mailbox starting at let's say 3 days ago and it synchronizes the entire mailbox. (starting few months back)

Not Able to Login with Gmail

Describe the bug

A clear and concise description of what the bug is.
I install the imapapi package and then try to start it with Gmail. But I try many things It is showing the following error.

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Invalid input",
  "fields": [
    {
      "message": "\"IMAP\" contains a conflict between exclusive peers [useAuthServer, Authentication]",
      "key": "imap"
    },
    {
      "message": "\"SMTP\" contains a conflict between exclusive peers [useAuthServer, Authentication]",
      "key": "smtp"
    }
  ]
}

and I try to register with these details:

{
  "account": "example",
  "name": "My Email Account",
  "copy": true,
  "notifyFrom": "2020-01-01",
  "imap": {
    "auth": {
      "user": "[email protected]",
      "pass": "******"
    },
    "useAuthServer": true,
    "host": "imap.gmail.com",
    "port": 993,
    "secure": true
  },
  "smtp": {
     "auth": {
      "user": "[email protected]",
      "pass": "******"
    },
    "useAuthServer": true,
    "host": "smtp.gmail.com",
    "port": 587,
    "secure": true
  }
}

I also try to pass the auth token which I generate from Google Gmail API but it was not working.

Payload content length greater than maximum allowed: 1048576 ?

I send file attachment just 1MB file from multer buffer, but error
{ statusCode: 413, error: 'Request Entity Too Large', message: 'Payload content length greater than maximum allowed: 1048576' }

I read in the documentation that the maxLength file limit: 5242880. what's wrong ? . Thank you for your help.

Production Use?

Sorry, i know this isn't a bug, not sure where to ask these questions
Has this been used in production?
About how many users?
Are there any known concerns/issues for not running this in production?
(lets assume the external authentication is solid, redis is an enterprise deployment, mail servers are our own and scaled properly)
We have some very specific requirements for a new email system and this looks like a good piece of the puzzle. Potentially tens of thousands of users.

How to get all messages sent by account?

Is your feature request related to a problem? Please describe.
I would like to query all messages that an account has sent ( as "from")

Describe the solution you'd like
Query by FROM on /search endpoint would also consider the messages sent by account not only received

Describe alternatives you've considered
Include in the TO array, the account set in FROM (send to myself)

How to submit message directly to an mailbox besides INBOX

Is your feature request related to a problem? Please describe.
Looking in away to avoid to request the the endpoint PUT /v1​/account​/{account}​/message​/{message}​/move

Describe the solution you'd like
Send an message directly to an specific mailbox, maybe a new param at /submit endpoint

Throwing Gateway time-out (504 status) error for multiple calls to the IMAP APIs

Hi @andris9 ,
I'am getting status error 504 i.e. Gateway Time-out in the following scenario's :

  1. When I try to fetch mails which received in last few days (there are more number of mails in the All Mail folder), I need to make a multiple API calls by giving page index to this API : http://127.0.0.1:3000/v1/account/123456/search?path=[Gmail]/All Mail&page=0&pageSize=1000 at that time Iam getting 504 status Error.

  2. When I try to fetch a attachment by attachment-id using promise collection. Here also I'am getting the 504 status error for some times.

Is there any API call limits to the IMAP APIs?

Error: self signed certificate at TLSSocket.onConnectSecure

Describe the bug
I'm not sure if this is a bug or not, but I can't connect anymore to the account I previously could connect. It says that there is some kind of problem with ssl, but at this point I'm not sure why. Only difference to what I was doing before is that I've changed my computer, I got new one.

To Reproduce
Steps to reproduce the behavior:

  1. Run npx imapapi --dbs.redis="redis://127.0.0.1:6379"
  2. Create account:
curl -XPOST "localhost:3000/v1/account" -H "content-type: application/json" -d '{
    "account": "example",
    "name": "My Example Account",
    "imap": {
        "host": "<your-address>",
        "port": 143,
        "secure": false,
        "auth": {
            "user": "<your-account>",
            "pass": "<account-password>"        
        }
    },
    "smtp": {
        "host": "<your-address>",
        "port": 587,
        "secure": false,
        "auth": {
            "user": "<your-account>",
            "pass": "<account-password>"        
        }
    }
}'
  1. See error
{"level":50,"time":1599900200040,"pid":35652,"hostname":"Petars-MacBook-Pro.local","tid":1,"component":"imap-client","account":"example","cid":"p5z2cthej55ac95qj3yw","sub":"imap-connection","err":{"type":"Error","message":"self signed certificate","stack":"Error: self signed certificate\n    at TLSSocket.onConnectSecure (_tls_wrap.js:1501:34)\n    at TLSSocket.emit (events.js:315:20)\n    at TLSSocket._finishInit (_tls_wrap.js:936:8)\n    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:710:12)","code":"DEPTH_ZERO_SELF_SIGNED_CERT"},"cid":"1b2ngnrkkokz1ejy9wzf"}
{"level":50,"time":1599900200041,"pid":35652,"hostname":"Petars-MacBook-Pro.local","tid":1,"component":"imap-client","account":"example","cid":"p5z2cthej55ac95qj3yw","msg":"IMAP connection error","account":"example","err":{"type":"Error","message":"self signed certificate","stack":"Error: self signed certificate\n    at TLSSocket.onConnectSecure (_tls_wrap.js:1501:34)\n    at TLSSocket.emit (events.js:315:20)\n    at TLSSocket._finishInit (_tls_wrap.js:936:8)\n    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:710:12)","code":"DEPTH_ZERO_SELF_SIGNED_CERT"}}
{"level":50,"time":1599900200041,"pid":35652,"hostname":"Petars-MacBook-Pro.local","tid":1,"component":"imap-client","account":"example","cid":"p5z2cthej55ac95qj3yw","msg":"Failed to connect","account":"example","err":{"type":"Error","message":"Unexpected close","stack":"Error: Unexpected close\n    at ImapFlow.close (/Users/developera/.npm/_npx/35652/lib/node_modules/imapapi/node_modules/imapflow/lib/imap-flow.js:1116:20)\n    at Immediate.<anonymous> (/Users/developera/.npm/_npx/35652/lib/node_modules/imapapi/node_modules/imapflow/lib/imap-flow.js:490:41)\n    at processImmediate (internal/timers.js:456:21)"}}

Desktop (please complete the following information):

  • OS: macOS Catalina 10.15.6

**Adittional context
Username and password are correct, I can log in into mailbox. IMAP and SMTP ports are also correct, I've tested connection with telnet

Attachment size

In api.js there is hardcoded size of attachment(5Mb). I think it would be a good idea to make it possible to modify size of attachments we want to send.

OFFICE365 - textType plain/html not work

Version 1.4.6

Retrieves message text - this endoint returns content of mail. If I specified textType to plain or html, I get empty string. But if I pass * as textType I get html in field 'plain'.

After adding more logs I found error - file /lib/connection.js in function getText(textId, options) in line 767.
If I pass textType as "html" a variable "result" should have field "html" but has only "plain" and vice versa.

Provide docker compose file and docker image for simple deployment

Is your feature request related to a problem? Please describe.
For QA to use this tool, it would be complex to setup the environment with many npm commands.

Describe the solution you'd like
We can provide a docker compose file and a docker image, then QA can setup the environment with one single command

docker-compose up -d

Ref:
https://github.com/MiffyLiye/imapapi/blob/master/Dockerfile
https://github.com/MiffyLiye/imapapi/blob/master/docker-compose.yaml

Internal Server Error - get text of message

Version 1.4.6

When I try to get text for message where there is no text nor html I get Internal Server.
In raw message there is:
some headers
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.5.23 (2014-03-12)
some headers

In normal email where sb write something after text/plain there is some text. In this problematic email there is no text nor html.
I think IMAPAPI should return null or empty string.

"err":{"type":"IncompleteBufferError","message":"unable to decode","stack":"IncompleteBufferError: unable to decode\n at Object.decode (/usr/local/conpeek/apis/imapapi/node_modules/msgpack5/lib/decoder.js:51:24)\n at Connection.getMessageTextPaths (/usr/local/conpeek/apis/imapapi/lib/connection.js:191:33)\n at Connection.getText (/usr/local/conpeek/apis/imapapi/lib/connection.js:737:49)\n at ConnectionHandler.getText (/usr/local/conpeek/apis/imapapi/workers/imap.js:167:45)\n at ConnectionHandler.onCommand (/usr/local/conpeek/apis/imapapi/workers/imap.js:441:35)\n at MessagePort. (/usr/local/conpeek/apis/imapapi/workers/imap.js:561:14)\n at MessagePort.emit (events.js:315:20)\n at MessagePort.onmessage (internal/worker/io.js:78:8)\n at MessagePort.exports.emitMessage (internal/per_context/messageport.js:11:10)","name":"IncompleteBufferError"}}

Emails not threaded

While listing messages lists all messages correctly in chronological order, it doesn't thread any emails. Since it is paged this makes it nearly impossible to build a message thread syntactically.

I'm wondering if this is intended behaviour + if so, is threading on the roadmap?

Desktop (please complete the following information):

  • OS: WSL 2

Some messageIds contain forward slash '/' and fails api requests that use messageId as path parameter

Describe the bug
Some messageIds contain forward slash '/'. And fails when api calls when it is used as the path parameter even when encodeURIComponent(messageId).

To Reproduce
I think to reproduce the behaviour try to fetch as many messageIds as possible and check. There's no direct way to reproduce.

Expected behavior
Expecting all messageId's to be free of '/'.

Desktop (please complete the following information):

  • OS: iOS

Additional context
Also checked via swagger. It fails there as well as shown in the screenshot.

IMAP API messageIds

IMAP API Server Swagger

Mailboxes do not resync with servers with no CONDSTORE CAPABILITY eg office365

As the topic.
The server does not return the HIGHESTMODSEQ parameter in SELECT / EXAMINE queries.
In the mailbox.js on line 223:

status.highestModseq = status.highestModseq || false;

causes status.highestModseq to always be false.

Code on line 242:

if ((! status.messages &&! storedStatus.messages) || status.highestModseq === storedStatus.highestModseq) {
    // no reason to sync
    return true;
}

causes synchronization to never take place.

The simplest way for me was to change it to:

if ((! status.messages &&! storedStatus.messages) || (status.highestModseq! = false && status.highestModseq === storedStatus.highestModseq)) {
    // no reason to sync
    return true;
}

Regards Adam

Office 365 webhooks

When I send a message through office 365 mailbox webhook comes with long delay, around 15-20 seconds. Is there any way to get those webhooks almost instantly? Gmail works much faster.

[doubts]: Message ID and Attachment ID is unique for all the messages in Gmail account?

Hi @andris9 ,

I have few questions that listed below:

  1. Whenever I get a new message notification in my application from the IMAP API webhooks,
    I'am going to store the new message ID (i.e data.id) and Attachment ID(i.e.attachments[0].id) into my database. Using these messageID and attachmentID, I'am trying to fetch those email information in the future by making use of GET : ​/v1​/account​/{account}​/message​/{message} and GET: ​/v1​/account​/{account}​/attachment​/{attachment} respectively.
    Here my question is, these messageID and attchamentID will be unique in future as well right? otherwise there might be possible of fetching of wrong information for the given messageID and attachmentID. It leads to more issues.
  2. Using query search options, can I get a all the messages received in last 24 hours from a particular domain only.
    ex: Get all received messages in last 24 hours for the domain outlook.com by using like this $ curl "http://localhost:4452/v1/account/gmail/messages?path=INBOX&search[unseen]=true

Thanks.

Plans to support moving messages

first things first. awesome project!
I've been tinkering with it for some personal automation today and Im really excited!

I noticed that the swagger docs dont mention any way of moving messages between boxes, however imapflow does seem to support this.

is this possible with imapapi? Is something like this in the making? or can i perhaps contribute to make this possible?

Cheers,

Midge

Calling IMAP APIs immediately after registering an account

I have a problem when calling the IMAP APIs e.g mailboxes, messages after calling the register account API.
The account's state is Init then I call other APIs immediately, this API will show the error as the screenshot below
Kazam_screenshot_00004

But wait until the partial sync is completed (a long time with lots of emails) and the state is Connected, I can call it smoothly.

My expected is when the user account is registered, the user can get the messages or mailboxes immediately because my system has a lot of email accounts and I don't know how long to wait for the sync will be completed.

Do we have the solution to open the box to call APIs and sync parallel ones?

Should be possible to update Setting w/o Webhook URL

Describe the bug
Should be possible to update Setting w/o Webhook URL

To Reproduce
Steps to reproduce the behavior:

  1. Go to IMAP API -> 'Settings'
  2. Attempt to add an account in logs section

Expected behavior
it gets added

actual
Not saved because Webhook URL is blocking the form to submit

is there any workaround to get it added directly in the setting file?

Interact with labels through the API

Is your feature request related to a problem? Please describe.

I haven't found a way to add / delete / set labels using the API.

This is especially missing with Gmail:
when you move a message with the API, Gmail adds a label, so there is no way to really MOVE a mail to another folder.

Describe the solution you'd like

Right now, in the PUT message API, we can set flags:

{
  "flags": {
    "add": [],
    "delete": [],
    "set": []
  }
}

Add the option to set labels,

{
  "flags": {
    "add": [],
    "delete": [],
    "set": []
  },
  "labels": {
    "add": [],
    "delete": [],
    "set": []
  }
}

The rest of the API looks perfect,
the GET message returns flags and labels, and the webhook shows flags and label changes.

Describe alternatives you've considered

Deleting and recreating messages. That would be monstrous :)

Thanks again for sharing this API,
happy to help if needed.

Update flag events not notifying through webhooks

Hi @andris9 ,

Whenever new emails comes to the register email account with IMAP will notify to my application through webhooks. But whenever I unread an email, those update flags notifications not triggering by the webhooks(But update flags notifications will get when I run the code local but not on the server).

Thanks.

Message "id" and text "id" contains slash /

Thank you very much for this tool.
I 'm trying the imap api for the last week now and so far it looks very promising for my project.
But as of today any new message i get. their id and their text id are containing a slash /. And i can't use the ids to make request for individual message or message's text. I get status 404. Not Found.
I took a look on the code to try to understand how the id is created with no luck. As i understand it the id is a combination of message's uid, mailbox and something else?
Is it really a problem for the id to contain a slash or is it normal and there is another way to overcome this "inconvenient" when making a request for this particular id?
Would be practical to make a request for a message using it's uid and path as a parameter?

To Reproduce
1 . Make a request for a list of messages for Inbox. I get the list correctly.
2. Then i copy the "id" (AAAAAQAA9/g) of the message i am interesting in and make a new request for the individual message info ( ​/v1​/account​/{account}​/message​/{message}).
3. Get status code 404 Not Found.
4. Same when requesting text with it's id "AAAAAQAA9/iTkaExkJA"

Connecting an account takes longer than 5min.

Describe the bug
After initial setup of an account. The time taken for the account to move state from 'init' to 'connected' takes almost 5 minutes. Is this expected?

To Reproduce
Steps to reproduce the behavior: A simple account creation process.

Expected behavior
Expected to move account state from 'init' to 'connected' quickly. This can be seen in the previous versions such as '1.1.0'

Desktop (please complete the following information):

  • OS: iOS Big Sur

Additional context
I am using the latest version of the imapapi v1.3.6.

Can't pass authToken in smtp

Hi there, thanks for maintaining and sharing this tool,

Describe the bug
I try to set up an account with imap and SMTP to connect to Gmail. Using their OAuth script I generated an access token.
It seems to work fine with imap, but when I try to set the SMTP auth I get the following error:

{"statusCode":400,"error":"Bad Request","message":"Invalid input","fields":[{"message":"\"smtp.auth.pass\" is required","key":"pass"}]}

With a password, for the sake of completeness:

{"statusCode":400,"error":"Bad Request","message":"Invalid input","fields":[{"message":"\"smtp.auth.pass\" is not allowed to be empty","key":"pass"},{"message":"\"Authentication\" contains a conflict between exclusive peers [pass, accessToken]","key":"auth"}]}%                                                                                                                                       

To Reproduce
Steps to reproduce the behavior:

API_PORT=8123 npx imapapi --dbs.redis="redis://127.0.0.1:6379" --api.port=8123 --api.host=127.0.0.1

curl -X POST "http://127.0.0.1:8123/v1/settings" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"webhooks\": \"${WEBHOOK_API}"}"

DATA=$(cat <<EOF
{
  "account": "${GMAIL_EMAIL}",
  "name": "${GMAIL_EMAIL}",
  "copy": true,
  "notifyFrom": "2021-03-03",
  "imap": {
    "auth": {
      "user": "${GMAIL_EMAIL}",
      "accessToken": "${GMAIL_ACCESS_TOKEN}"
    },
    "host": "imap.gmail.com",
    "port": 993,
    "secure": true,
    "tls": {
      "rejectUnauthorized": true,
      "minVersion": "TLSv1.2"
    },
    "resyncDelay": 900
  },
  "smtp": {
    "auth": {
      "user": "${GMAIL_EMAIL}",
      "accessToken": "${GMAIL_ACCESS_TOKEN}"
    },
    "host": "smtp.gmail.com",
    "port": 587,
    "secure": false,
    "tls": {
      "rejectUnauthorized": true,
      "minVersion": "TLSv1.2"
    }
  }
}
EOF)

echo "${DATA}"

curl -X POST "http://127.0.0.1:8123/v1/account" -H "accept: application/json" -H "Content-Type: application/json" -d "${DATA}"

Expected behavior

I expect the API to be OK with my payload and let me send an access token without pass.

Screenshots

In swagger, there is a "Model1" that looks buggy:
Screenshot 2021-03-03 at 13 23 44

Desktop:

macos, node 12.20

Init Stage

Hi @andris9

Not a bug report, but also not a feature request, more like a "General"

I've noticed that a mailbox seems to get 'stuck' on the init stage after first setup sometimes. Probably not stuck, but it will sit on the init stage for 45 minutes to an hour. I've noticed this for bigger mailboxes. What happens during the init stage that could be causing these delays?

I haven't waited it out yet, normally after about half an hour I will request a reconnect which sometimes gets the mailbox to the connecting then connected state, or sometimes if it really doesn't want to move, I remove and add that account back, and then it pretty quickly gets connected.

When setting up a new account, I set the syncsince to today or yesterday in an attempt to make the initial setup a bit faster, but I'm not sure if that actually makes a difference.

Any ideas on this long init stage? Should it just be waited out even if it takes longer than an hour?

Regards

OAuth2 does not work with SMTP

Nodemailer uses slightly different OAuth2 configuration that ImapFlow, so currently tokens are generated but Nodemailer can not use these.

Todo:

  • Edit SMTP OAuth2 token handling in a way that the tokens are converted to a form that is usable by Nodemailer

502 when trying to create an account

Describe the bug

I tried to create account throught /v1/account and got 502

In logs i see
is.

To Reproduce
Steps to reproduce the behavior:

  1. Install imapapi throught npm i -g imapapi on ubuntu with default redis server from apm
  2. Make a request with curl
    curl -XPOST "http://127.0.0.1:3000" -H "content-type: application/json" -d '{"account":"[email protected]","name":"[email protected]","imap":{"auth":{"user":"[email protected]","pass":"pass"},"host":"imap.126.com","port":993,"secure":true,"tls":{"rejectUnauthorized":false},"resyncDelay":900},"smtp":{"auth":{"user":"faradaytrs","pass":"pass"},"host":"smtp.126.com","port":443,"secure":true,"tls":{"rejectUnauthorized":false}}}'
  3. curl: (52) Empty reply from server
  4. See logs and find
    {"level":60,"time":1609315386333,"pid":78627,"hostname":"globus","tid":11,"msg":"unhandledRejection","err":{"type":"TypeError","message":"Cannot read property 'statusCode' of null","stack":"TypeError: Cannot read property 'statusCode' of null\n at Request._finalize (/usr/lib/node_modules/imapapi/node_modules/@hapi/hapi/lib/request.js:497:31)\n at Request._reply (/usr/lib/node_modules/imapapi/node_modules/@hapi/hapi/lib/request.js:434:18)\n at Request._execute (/usr/lib/node_modules/imapapi/node_modules/@hapi/hapi/lib/request.js:280:14)\n at processTicksAndRejections (node:internal/process/task_queues:93:5)"}}
    A clear and concise description of what the bug

Expected behavior
A clear and concise description of what you expected to happen.
Expected normal behavior

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] OS: Ubuntu 20.04.1 LTS x86_64 Kernel: 5.4.0-58-generic
  • Browser [e.g. chrome, safari] curl, the same with edge and firefox
  • Version [e.g. 22] edge 87

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.