Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Received mails not detecting for the SMTP server in my application #143

Open
vinodhreddygs opened this issue Apr 23, 2020 · 1 comment
Open

Comments

@vinodhreddygs
Copy link

vinodhreddygs commented Apr 23, 2020

Hi,
Using the smtp-server listener Iam trying to receive mails. (But Authentication is not happening. Even emails are not detecting).
Please check the below code snippet that iam using and let me know if I have done any wrong.
(No consoles are printing expect console.log("starts listening on 465>>>") in the below code snippet).

var SMTPServer = require('smtp-server').SMTPServer;


var server = new SMTPServer({
    tls:true,
    logger: true,
    onAuth(auth, session, callback) {
        console.log("Console in auth function>>>",auth);
        if (auth.username != config.mail_username || auth.password != config.mail_password) {
          return callback(new Error("Invalid username or password"));
        }
        console.log("Authentication successfull>>>")
        return callback();
    },
    onConnect(session, callback) {
        console.log("Console in onConnect function>>>",session);
        if (session.remoteAddress === "127.0.0.1") {
          return callback(new Error("No connections from localhost allowed"));
        }
        return callback(); // Accept the connection
    },
    onMailFrom(address, session, callback) {
        console.log("Received mail from function>>>",address);
        if (address.address !== "[email protected]") {
          return callback(
            new Error("Only [email protected] is allowed to send mail")
          );
        }
        return callback(); // Accept the address
    },
    onData(stream, session, callback) {
        console.log("Console at onData function>>>",onData);
        stream.pipe(process.stdout); // print message to console
        stream.on("end", callback);
      }
});
// mailListener.listen(465) // start listening
server.listen(465, function () {
console.log("starts listning on 465>>>")
})
server.on("error", err => {
    console.log("Error %s", err.message);
  });

server.on('error', err => {
    console.log("Error on server start",err.message);
  });

server.listen(465);
@vinodhreddygs vinodhreddygs changed the title Authentication is not happening Received mails not detecting for the SMTP server in my application Apr 23, 2020
@andrealeo83
Copy link

Same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants