SMTP to SMTP protocol
I am trying to write a fake SMTP server in nodejs, I just need use it to send 开发者_如何转开发notify email, but not receive email.
I have taken a look at node-smtp, but it just implements the protocol from client to SMTP server, it does not implement how to send mail from a SMTP server to another SMTP server.
If I know how one SMTP server send mail to another SMTP server, I think I can send mail without a SMTP server.
but it just implements the protocol from client to SMTP server, it does not implement how to send mail from a SMTP server to another SMTP server.
An SMTP server that can send mail also acts as an SMTP client. Not that you're trying to write an SMTP server anyway:
I just need use it to send notify email, but not receive email.
aka
I just need to write an SMTP client
Well in short it works this way: server-sender reads domain of recipient and is checking DNS for MX record for that domain (you can read it like - "hey DNS tell me please which server holds mails for that domain). Then it connects to remote SMTP and gives the messaage. The dialogue could look like this:
client: HELLO server
server: 250 hello client, nice to meet you
client: MAIL FROM: tmg
server: 250 ok
client: RCPT TO: guilin
server: 250 ok
client: data
server: 354 Enter message, ending with "." on a line by itself
client: From: tmg
client: To: guilin
client: Subject: just a mail
client:
client: message body
client: .
server: 250 ok
client: quit
server: good bye
Did you look at Marak's node_mailer?
https://github.com/Marak/node_mailer
I have a fork of it, and another one, on my github site, for gmail smtp support
http://github.com/deitch
I use https://github.com/andris9/simplesmtp, it is actually a framework for creating SMTP servers/clients, however it is quite a good fit for testing.
There is also https://github.com/deitch/smtp-tester specially designed for testing, however I haven't used it.
精彩评论