nodejs smtp-server Email gets sent but not received

后端 未结 2 1494
广开言路
广开言路 2021-01-15 14:42
const nodemailer = require(\'nodemailer\');

const SMTPServer = require(\"smtp-server\").SMTPServer;

const server = new SMTPServer({
    onAuth(auth, session, callb         


        
相关标签:
2条回答
  • 2021-01-15 15:19

    I think you might simply be queuing the email in your instance of smtp-server and not actually sending it.

    The documentation for smtp-server begins with a note about how this module does not actually send emails by itself:

    This module does not make any email deliveries by itself. smtp-server allows you to listen on ports 25/24/465/587 etc. using SMTP or LMTP protocol and that’s it. Your own application is responsible of accepting and delivering the message to destination.

    You will need to use the SMTP client module smtp-connection in conjunction with your SMTP server to send the email.

    You can see where the "250 OK: message queued" response is coming from at this line in the server module's code.

    0 讨论(0)
  • 2021-01-15 15:19

    For who came with this same issue but using the Nodemailer's transporter way, I solved this issue adding the name of the server into the transporter object.

    
        const transportObj = {
          name: credentials.host, // in my case, the host and the name are the same
          host: credentials.host,
          port: credentials.port,
          secure: true,
          auth: {
              user: credentials.user,
              pass: credentials.pass
          },
    }
    
    const transporter = nodemailer.createTransport(transportObj)
    
    transporter.sendMail(...)
    
    

    This solution was related here

    0 讨论(0)
提交回复
热议问题