mirror of https://github.com/eleith/emailjs.git
smtp: trim host before connecting
This commit is contained in:
parent
513fb6ccc4
commit
b3fa0babf8
|
@ -163,8 +163,8 @@ client.send(message, (err, message) => {
|
|||
const options = {
|
||||
user, // username for logging into smtp
|
||||
password, // password for logging into smtp
|
||||
host, // smtp host
|
||||
port, // smtp port (if null a standard port number will be used)
|
||||
host, // smtp host (defaults to 'localhost')
|
||||
port, // smtp port (defaults to 25 for unencrypted, 465 for `ssl`, and 587 for `tls`)
|
||||
ssl, // boolean or object {key, ca, cert} (if true or object, ssl connection will be made)
|
||||
tls, // boolean or object (if true or object, starttls will be initiated)
|
||||
timeout, // max number of milliseconds to wait for smtp responses (defaults to 5000)
|
||||
|
@ -172,6 +172,8 @@ const options = {
|
|||
authentication, // array of preferred authentication methods ('PLAIN', 'LOGIN', 'CRAM-MD5', 'XOAUTH2')
|
||||
logger, // override the built-in logger (useful for e.g. Azure Function Apps, where console.log doesn't work)
|
||||
};
|
||||
// NOTE: `host` is trimmed before being used to establish a connection.
|
||||
// however, the original untrimmed value will still be visible in configuration.
|
||||
```
|
||||
|
||||
## client.Client#send(message, callback)
|
||||
|
@ -246,6 +248,8 @@ const options = {
|
|||
authentication, // array of preferred authentication methods ('PLAIN', 'LOGIN', 'CRAM-MD5', 'XOAUTH2')
|
||||
logger, // override the built-in logger (useful for e.g. Azure Function Apps, where console.log doesn't work)
|
||||
};
|
||||
// NOTE: `host` is trimmed before being used to establish a connection.
|
||||
// however, the original untrimmed value will still be visible in configuration.
|
||||
```
|
||||
|
||||
To target a Message Transfer Agent (MTA), omit all options.
|
||||
|
|
|
@ -25,6 +25,10 @@ export class Client {
|
|||
protected timer: NodeJS.Timer | null = null;
|
||||
|
||||
/**
|
||||
* Create a standard SMTP client backed by a self-managed SMTP connection.
|
||||
*
|
||||
* NOTE: `host` is trimmed before being used to establish a connection. however, the original untrimmed value will still be visible in configuration.
|
||||
*
|
||||
* @param {SMTPConnectionOptions} server smtp options
|
||||
*/
|
||||
constructor(server: Partial<SMTPConnectionOptions>) {
|
||||
|
|
10
smtp/smtp.ts
10
smtp/smtp.ts
|
@ -119,6 +119,8 @@ export class SMTPConnection extends EventEmitter {
|
|||
* SMTP class written using python's (2.7) smtplib.py as a base.
|
||||
*
|
||||
* To target a Message Transfer Agent (MTA), omit all options.
|
||||
*
|
||||
* NOTE: `host` is trimmed before being used to establish a connection. however, the original untrimmed value will still be visible in configuration.
|
||||
*/
|
||||
constructor({
|
||||
timeout,
|
||||
|
@ -208,6 +210,10 @@ export class SMTPConnection extends EventEmitter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Establish an SMTP connection.
|
||||
*
|
||||
* NOTE: `host` is trimmed before being used to establish a connection. however, the original untrimmed value will still be visible in configuration.
|
||||
*
|
||||
* @public
|
||||
* @param {function(...*): void} callback function to call after response
|
||||
* @param {number} [port] the port to use for the connection
|
||||
|
@ -315,13 +321,13 @@ export class SMTPConnection extends EventEmitter {
|
|||
if (this.ssl) {
|
||||
this.sock = connect(
|
||||
this.port,
|
||||
this.host,
|
||||
this.host.trim(),
|
||||
typeof this.ssl === 'object' ? this.ssl : {},
|
||||
connected
|
||||
);
|
||||
} else {
|
||||
this.sock = new Socket();
|
||||
this.sock.connect(this.port, this.host, connectedErrBack);
|
||||
this.sock.connect(this.port, this.host.trim(), connectedErrBack);
|
||||
}
|
||||
|
||||
this.monitor = new SMTPResponse(this.sock, this.timeout, () =>
|
||||
|
|
Loading…
Reference in New Issue