Are there any SMTP servers written in PHP or Go?

I do not mean SMTP / IMAP clients , I mean working SMTP , which can receive and send e-mail.

There are many examples of partial PHP and Go SMTP servers that only listen on SMTP connections β€” are there any messages about how to send mail?

I am very interested in learning this second half of Simple Mail Transfer Protocol. I understand that there are many bad servers that differ from the standard, but I want to find out how the entire protocol is implemented from start to finish.

+6
source share
5 answers

I think you misunderstood how SMTP should work. Here is a simplified version:

  • The mail user agent (MUA) queues the message for delivery by sending it to the mail sending agent (MSA).

  • The MSA connects to the mail transfer agent ("smtp server") through SMTP.

  • The MTA then uses DNS to search for the MX record for the recipient domain. It then contacts the MX recipient server as an SMTP client.

  • The MX server accepts the envelope; He then forwards it to the mail delivery agent (MDA).

  • The MDA then places the envelope in some message store, where some IMAP or POP3 server reads the messages. The MUA then connects to these servers to receive the message.

The whole process uses three main commands. MAIL , RCPT and DATA .

  • MAIL = envelope information, failure addresses, etc.
  • RCTP = Recipient.
  • DATA = Payload.

The SMTP server responds - like HTTP actually, with error codes and, based on this, the MTA knows what to do with the envelope (bounce it back, so send the appropriate response, etc.)

There is no such thing as β€œreceive email” in this process (slightly ignoring ETRN ); since SMTP is for email only, not for retrieval.

+13
source

I found a complete one written in PHP - even includes a nasty open relay.

 $ sudo php php-smtp.php [ip-address] [port] 
+2
source

There is no "second half" SMTP, only the protocol. If your MUA communicates directly via TCP with the mail server (instead of using an auxiliary program such as the / usr / bin / sendmail binary found on most Unix), it uses the SMTP protocol. MTA uses the same protocol to talk with other MTAs when delivering mail. He can use the larger set of available verbs, as the case may be.

When you see the MTA PHP or Go implementation code, you will see how one person / team implemented the SMTP protocol.

+1
source

As a PHP server smtpd that just handles mail - https://github.com/flashmob/Guerrilla-SMTPd and the exit port https://github.com/flashmob/go-guerrilla

+1
source

There is no non-blocking SMTP server written in PHP on top of ReactPhp:

https://bitbucket.org/david_garcia_garcia/smtpserver

It is intended for the end user to create custom implementations of authentication and delivery, the rest of the SMTP behavior works out of the box.

+1
source

Source: https://habr.com/ru/post/926535/


All Articles