nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

What happens after 250 OK: message queued ? #130

Closed realtebo closed 4 years ago

realtebo commented 4 years ago

I started to play with this tool, so thanks in advance.

I succesfully sent 3-4 mail from my pc using thunderbird using plain text auth to my yahoo mail address.

After a while, mail are no more received. So I opened a tempmail address to be sure to not being blocked from any server filters.

I still do not receive no more mail. Actually all I am doing is

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

const server = new SMTPServer({
    logger: true,
    debug: true,
    auth: null,
    allowInsecureAuth: true,

    onMailFrom(address, session, callback) {
        console.log ("---- Email FROM --- " );
        console.dir (address);
        console.log ("-----------------------");
        return callback(); // Accept the address
    },

    onRcptTo(address, session, callback) {
        console.log ("---- Email TO --- " );
        console.dir (address);
        console.log ("-----------------------");
        return callback(); // Accept the address
    },

    onAuth(auth, session, callback) {
        return callback(null, { user: { id: session.id} });
    }
});

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

server.listen(465);

Is am doing wrong something?

What happens after 250 OK ? Can we debug in some way the dialog from our smtp and the target mail rcpt ?

realtebo commented 4 years ago

I happend a log of a try of sending - this mail has never been delivered

[2019-07-11 15:07:30] INFO  SMTP Server listening on [::]:465
[2019-07-11 15:10:21] ERROR [#s3v75cntkzyhuly7] Reverse resolve for ::1: getHostByAddr ENOTFOUND ::1
[2019-07-11 15:10:21] INFO  [#s3v75cntkzyhuly7] Connection from [::1]
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 220 DESKTOP-G7KIN0A ESMTP
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] C: EHLO [IPv6:::1]
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 250-DESKTOP-G7KIN0A Nice to meet you, [::1]
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] 250-PIPELINING
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] 250-8BITMIME
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] 250-SMTPUTF8
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] 250-AUTH LOGIN PLAIN
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] 250 STARTTLS
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] C: AUTH PLAIN AG1pcmtvAGJhdSBiYXU=
[2019-07-11 15:10:21] INFO  [#s3v75cntkzyhuly7] mirko authenticated using PLAIN
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 235 Authentication successful
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] C: MAIL FROM:<redacted but was right> BODY=8BITMIME
---- Email FROM --- 
{ address: '<redacted but was right>',
  args: { BODY: '8BITMIME' } }
-----------------------
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 250 Accepted
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] C: RCPT TO:<nujigog@simplemail.in>
---- Email TO --- 
{ address: 'nujigog@simplemail.in', args: false }
-----------------------
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 250 Accepted
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] C: DATA
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 354 End data with <CR><LF>.<CR><LF>
[2019-07-11 15:10:21] INFO  <received 464 bytes>
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] C: <464 bytes of DATA>
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 250 OK: message queued
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] C: QUIT
[2019-07-11 15:10:21] DEBUG [#s3v75cntkzyhuly7] S: 221 Bye
[2019-07-11 15:10:21] INFO  [#s3v75cntkzyhuly7] Connection closed to [::1]

Sending a mail with another smtp, the mail arrives to this address, without any problem. What am I doing wrong?

realtebo commented 4 years ago

OMG, I just realized that

smtp-server isn't really what you want. It's only for receiving incoming mail.

from another issue.

I discovered that previously mail was received because I was not really using my smtp... now that I am really using it, mail obviously do not go to no place, because, simply, our smtp server simply received it but it do not re-send to target rcpt.

Sorry

I close.

realtebo commented 4 years ago

Well. It is not the goal of this package.

realtebo commented 4 years ago

use nodemailer to send FROM the smtp TO the destination server. SMTP simply accept your mail from your client, then SMTP must use some transport system to effectively send the mail to the target

realtebo commented 4 years ago

Try to send to send to mailtrap to verify

avi333learn commented 1 year ago

Did anyone found solution to this as I am facing same issue. I have a SMTP server made using smtp-server on my domain (lets say example.com) and when i try to send mail using nodemailer with from "donotreply@example.com" to "sample.gmail.com" then I can see mail details in smtp server but mail never reaches gmail. Also on printing info in nodemailer i saw same message as mentioned by @brady444 " response: '250 OK: message queued'"

SaadatKosumbaeva commented 1 year ago

@avi333learn , I faced the same problem, did you manage to solve it?

realtebo commented 1 year ago

Depends on what is your problem about.

Remember: the goal of this package is not to send mail to destination address.

If you want a real smtp server you can use nodemailer for example Or the python script named sendemail (note the 2nd 'e' letter)

avi333learn commented 1 year ago

@avi333learn , I faced the same problem, did you manage to solve it?

Yes, @SaadatKosumbaeva I was able resolve issue. Problem was that I wanted fully functional Emaill server but smtp-server is not made for that as described by @realtebo . Issue is old so can not remember exactly but mainly issue was that gmail server could not verify my server as it requires setting up SPF and DKIM. So, I went for setting up "POSTFIX" as my email server and then sent mail from "donotreply@example.com" to sample.gmail.com. That means I used nodemailer to send email but my email server was POSTFIX and not "smtp-server". If you are interested in setting up full server, you can follow steps in https://www.linuxbabe.com/mail-server/setup-basic-postfix-mail-sever-ubuntu I used part 1, 2 and 4 to setup email server. After these steps I could use nodemailer to send mail. For my server i needed to buy a domain name and a SSL certificate.