节点JS Mailin SMTP身份验证凭据

时间:2016-08-02 12:52:14

标签: node.js email smtp

我尝试开发我的SMTP服务器,为此任务我使用Mailin模块 - Mailin on GitHub

但是当我尝试授权用户时,我的Mailin SMTP服务器返回535错误(身份验证凭据无效)。

我的选项启动功能:

mailin.start({
    port: 2525,
    disableWebhook: true,
    smtpOptions: {
        banner: 'Hello Smtp Server',
        logger: true,
        requireAuthentication: true,
        authMethods: ['PLAIN', 'LOGIN'],
        disabledCommands: ['STARTTLS'],
        ignoreTLS: true,
    }
})

和我的用户身份验证事件监听器:

mailin.on('authorizeUser', function(connection, username, password, done) {
    console.log(username, password);
    done(null, true);
});

这是服务器日志:

info: Mailin Smtp server listening on port 2525
[2016-08-01 20:32:52] INFO: [Yl+t89fMiD31] Connection from [127.0.0.1]
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] S: 220 MacBook-Air-Egor.local ESMTP ePost Smtp Server
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] C: ehlo MacBook-Air-Egor.local
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] S: 250-MacBook-Air-Egor.local Nice to meet you, [127.0.0.1]
250-PIPELINING
250-8BITMIME
250-SMTPUTF8
250 AUTH PLAIN LOGIN
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] C: AUTH LOGIN
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] S: 334 VXNlcm5hbWU6
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] C: YWJj
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] S: 334 UGFzc3dvcmQ6
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] C: ZGVm
abc def
[2016-08-01 20:32:52] INFO: [Yl+t89fMiD31] Authentication failed for abc using LOGIN
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] S: 535 Error: Authentication credentials invalid
[2016-08-01 20:32:52] INFO: [Yl+t89fMiD31] Authentication error for abc using LOGIN
Unauthorized user
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] S: 535 Unauthorized user
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] C: 
[2016-08-01 20:32:52] DEBUG: [Yl+t89fMiD31] S: 500 Error: command not recognized
[2016-08-01 20:32:52] INFO: [Yl+t89fMiD31] Connection closed to [127.0.0.1]

那么,我做错了什么,以及为什么我会收到这个错误?

1 个答案:

答案 0 :(得分:0)

我知道在文档中它说要回复

private String convertDate(String mydate) {

        String date = mydate;
        String firstLetter = date.substring(0,4).toUpperCase();
        String restLetters = date.substring(4).toLowerCase();
        date = firstLetter+restLetters;

        DateTimeFormatter oldFormat = DateTimeFormatter.ofPattern("dd-MMM-yyyy", new Locale("en"));
    LocalDate parsedDate = LocalDate.parse(date, oldFormat);

    DateTimeFormatter newFormat = DateTimeFormatter.ISO_DATE;
    String newDate = parsedDate.format(newFormat);
   return newDate;
  }
文档done(null, { user: 123} ); // where 123 is the User id 中的

smpt-server docs ::相当于上面callback

免责声明......我在试图让这项工作成功时找到了这个答案,所以我不是专家:)