Giter VIP home page Giter VIP logo

node-pop3's People

Contributors

brettz9 avatar dependabot[bot] avatar lianxh avatar metafloor avatar wslee94 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

Watchers

 avatar  avatar  avatar

node-pop3's Issues

Error on `master`

While my code is working fine on the latest npm release, on master, I am getting this error:

Error { Error: Unknown command.
    at TLSSocket.<anonymous> (/Users/brett/node-login/node_modules/node-pop3/lib/Connection.js:105:23)
    at TLSSocket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    at Socket.ondata (internal/wrap_js_stream.js:64:22)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11) eventName: 'error', command: 'RETR 2' }
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: Unknown command.
    at TLSSocket.<anonymous> (/Users/brett/node-login/node_modules/node-pop3/lib/Connection.js:105:23)
    at TLSSocket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    at Socket.ondata (internal/wrap_js_stream.js:64:22)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
Emitted 'error' event at:
    at TLSSocket.<anonymous> (/Users/brett/node-login/node_modules/node-pop3/lib/Connection.js:108:26)
    at TLSSocket.emit (events.js:198:13)
    [... lines matching original stack trace ...]
    at readableAddChunk (_stream_readable.js:269:11)

I am using RETR as follows:

const [
    [statInfo],
    [retrInfo]
  ] = await Promise.all([
    // Get number of messages and size
    pop3.command('STAT'), // no args

    // Retrieval of message
    pop3.command('RETR', 2) // requires msg number
  ]);

Unhandled 'error' event

Hi,
It happened recently that testing connection with an outlook pop3 service my code kept erroring and crashing without possibility of catching the error.

The specific error is this one
`events.js:292
throw er; // Unhandled 'error' event
^

Error: Logon failure: unknown user name or bad password.
at TLSSocket. (/...path/src/server/node_modules/node-pop3/lib/Connection.js:177:24)
at TLSSocket.emit (events.js:315:20)
at TLSSocket.EventEmitter.emit (domain.js:467:12)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
at Socket.ondata (internal/js_stream_socket.js:77:22)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:467:12)
Emitted 'error' event on Pop3Command instance at:
at TLSSocket. (/...path/src/server/node_modules/node-pop3/lib/Connection.js:180:27)
at TLSSocket.emit (events.js:315:20)
[... lines matching original stack trace ...]
at Socket.EventEmitter.emit (domain.js:467:12) {
eventName: 'error',
command: 'PASS ****'
}
`

kinda like the one I opened the last year, the number 18.
But this time there's not much that I can do to prevent it, I'm pretty sure.
Could you please take a look at this?

LIST returns 265 messages

Hi,
This is more of a question than an issue, and I know it probably isn't anything to do with your library, but probably something to do with the POP3 protocol that I can't work out...
But when I fire off a LIST command to my GMail account it returns 265 messages every time, and they are from about 5 years ago. Is there any way to get the most recent messages instead of old ones? How come it is limited to 265? Presumably some behaviour of the server?
Many thanks for any advice.

Documentation requests

Hi,

This is an exciting project to have found. Eager to try it out!

  • Was just wondering if might wish to showcase await and Promise.all parallel loading, in the docs, refactoring:
pop3.connect()
  .then(() => pop3.command('USER', '[email protected]'))
  .then(() => pop3.command('PASS', 'example'))
  .then(() => pop3.command('STAT'))
  .then(([info]) => console.log(info)) // 100 102400
  .then(() => pop3.command('RETR', 1))
  .then(([info, stream]) => console.log(info)) // 1024 octets
  .then(() => pop3.command('QUIT'))
  .then(([info]) => console.log(info));

into this:

(async () => {

// These must be in order:
await pop3.connect();
await pop3.command('USER', '[email protected]');
await pop3.command('PASS', 'example');

const [
  [statInfo],
  [retrInfo, stream]
] = await Promise.all([
    pop3.command('STAT'),
    pop3.command('RETR', 1)
]);

console.log(statInfo); // 100 102400
console.log(retrInfo); // 1024 octets

const [quitInfo] = await pop3.command('QUIT');
console.log(quitInfo);

})();

(I see now that this cannot be safely done)

  • Should the other POP3 commands work with command if not in the examples? (the required commands RSET, NOOP, DELE, LIST, or the optional APOP or commands in other specs like AUTH, STLS, STARTTLS, CAPA, SASL, RESP-CODES, LOGIN-DELAY, PIPELINING, EXPIRE, and IMPLEMENTATION). If they work, do you think they should be exposed as their own methods?

  • I was also thinking you might want to link to https://tools.ietf.org/html/rfc1939 so people can get an understanding of the POP commands.

I could provide a PR if you like (assuming I have gotten it correct above).

  • And could you document this?

  • listify

Thanks!

Error upon QUIT

Hi,

I've gratefully gotten node-pop3 working without SSL/TLS, and although adding:

{
port: 995,
tls: true
}

...allows me to apparently connect, but after QUIT, I have been getting the following (though once I did not):

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: r.name=E2=80=9D.
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                                    </td>
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20
                                </tr>
                                <tr>
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20
                                    <td style=3D"padding: 15px 0 20px 0; ba=
ckground-color: #FFFFFF; border: 2px solid #E8E8E8; border-bottom: 2px soli=
d #FF6C2C;">
                                        <table width=3D"680" border=3D"0" c=
ellpadding=3D"0" cellspacing=3D"0" style=3D"background:#FFFFFF;font-family:=
'Helvetica Neue',Helvetica,Arial,sans-serif;">
                                            <tbody>
                                                <tr>
                                               
    at TLSSocket.<anonymous> (/Users/brett/node-login/node_modules/node-pop3/lib/Connection.js:112:23)
    at TLSSocket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    at Socket.ondata (internal/wrap_js_stream.js:64:22)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
Emitted 'error' event at:
    at TLSSocket.<anonymous> (/Users/brett/node-login/node_modules/node-pop3/lib/Connection.js:115:26)
    at TLSSocket.emit (events.js:198:13)
    [... lines matching original stack trace ...]
    at readableAddChunk (_stream_readable.js:269:11)

Any ideas what this might be? (I am in mainland China, so I don't know if there are any disruptions specific to how accessing foreign sites can often be disrupted, even for non-blocked sites).

Unhandled error event

Hi, I don't know if this is an issue, but:
after polling for a while, it gives me this error, and i can't seem to catch and handle it.
Do you have a suggestion, or could you tell what do i do wrong?

`events.js:292
throw er; // Unhandled 'error' event
^

Error: Disconnected for inactivity.
at Socket. (/Users/.../src/server/node_modules/node-pop3/lib/Connection.js:176:24)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:467:12)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Emitted 'error' event on Pop3Command instance at:
at Socket. (/Users/.../src/server/node_modules/node-pop3/lib/Connection.js:180:27)
at Socket.emit (events.js:315:20)
[... lines matching original stack trace ...]
at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
eventName: 'error',
command: 'PASS password'
}
[nodemon] app crashed - waiting for file changes before starting...`

Not compatible with AWS Lambda

So the lib is working well on my local machine (thanks for 0.6.0 update) - but as soon as I use in a handler in AWS LAmbda, I get this:

"errorMessage": "Cannot call write after a stream was destroyed",
  "trace": [
    "Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed",
    "    at doWrite (_stream_writable.js:399:19)",

unfortunately I don't understand it much - but it is some sort of lifecycle issue where a write is trying to happen after the stream has been closed. It's specifically related to this library - as soon as I remove it, everything else works, including other promise-based libraries.

Created TypeScript type definitions.

I have created a TypeScript type definition.

If you like the type definitions I have created, I would be happy to include them in the package if you like.

import { type Stream } from 'node:stream';
import { type TlsOptions } from 'node:tls';

export type Pop3Options = {
    user: string;
    password: string;
    host: string;
    port?: number | undefined;
    servername?: string | undefined;
    tls?: boolean | undefined;
    timeout?: number | undefined;
    tlsOptions?: TlsOptions | undefined;
};

declare class Pop3Command {
    private user: string;

    private password: string;

    private host: string;

    private port?: number;

    private servername?: string;

    private tls: boolean | undefined;

    private timeout: number | undefined;

    private tlsOptions: TlsOptions | undefined;

    constructor(options: Pop3Options);
    connect(): Promise<void>;

    /* param example command("RETR", 1)  */
    command(...param: any): [string, Stream];
    UIDL(msgNum?: string | number): Promise<string[][]>;
    LIST(msgNum?: string | number): Promise<string[][]>;
    RETR(msgNum: string | number): Promise<string>;
    TOP(msgNum: number, line?: number): Promise<string>;
    QUIT(): Promise<string>;
    STAT(): Promise<string>;
    DELE(msgNum: string | number): Promise<string>;
    RSET(): Promise<string>;
    NOOP(): void;
}

export default Pop3Command;

Text As HTML do not cast spaces of received mail into HTML format

When i m writing an mail. I have kept two spaces between each line.
But when i receive mail using pop 3 and parsed it will generate textASHtml which not contains that spaces in terms of a break.
image (10)

This is a parsed mail of the above screen shot.

({"attachments":[],"headers":{},"headerLines":[{"key":"return-path","line":"Return-Path: "},{"key":"x-original-to","line":"X-Original-To: [email protected]"},{"key":"delivered-to","line":"Delivered-To: [email protected]"},{"key":"received","line":"Received: from [192.168.56.105] (unknown [192.168.56.105])\r\n\tby e681b1c03534.GSLAB.COM (Postfix) with ESMTPS id 0ADF71237BE\r\n\tfor ; Thu,  8 Aug 2019 07:06:19 +0000 (UTC)"},{"key":"to","line":"To: Tejas "},{"key":"from","line":"From: nupur "},{"key":"subject","line":"Subject: 34"},{"key":"message-id","line":"Message-ID: "},{"key":"date","line":"Date: Thu, 8 Aug 2019 12:36:18 +0530"},{"key":"user-agent","line":"User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\r\n Thunderbird/60.6.1"},{"key":"mime-version","line":"MIME-Version: 1.0"},{"key":"content-type","line":"Content-Type: text/plain; charset=utf-8; format=flowed"},{"key":"content-transfer-encoding","line":"Content-Transfer-Encoding: 7bit"},{"key":"content-language","line":"Content-Language: en-US"}],"text":**"12321\n\n\n321313\n\n\n\n3213\n","textAsHtml**":"

12321

321313

3213

"**,"subject":"34","date":"2019-08-08T07:06:18.000Z","to":{"value":[{"address":"[email protected]","name":"Tejas"}],"html":"Tejas <[email protected]>","text":"Tejas "},"from":{"value":[{"address":"[email protected]","name":"nupur"}],"html":"nupur <[email protected]>","text":"nupur "},"messageId":"","html":false})

Timeout issue in TOP/RETR commands.

When executing Pop3Command.TOP() or Pop3Command.RETR() with timeout specified, it becomes unresponsive if timeout occurs during reception. Probably, a mechanism is needed to abort this._stream in the callback argument of socket.setTimeout() in Connection.js if this._stream exists.

Thanks!

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.