Good day comrades! Let's imagine that the mail server with the name pwon.pp.ua received a letter from the client user htaccess@pwon.pp.ua and is going to send this letter to the user arsh-andrej@mail.ru.

And immediately the question: how to exchange mail between servers, how to communicate for this server with each other?

I wrote code in PHP and even managed to talk a bit with the mail.ru mail server.

<?php header('Content-Type: text/html; charset=utf-8'); # $opensocket_0 = fsockopen('smtp.mail.ru', 25, $errorcode, $errortext); # if ($opensocket_0 !== false) { //echo 'Подключено'; echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'HELO mail.pwon.pp.ua '."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'MAIL FROM: <htaccess@pwon.pp.ua>'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'RCPT TO: <arsh-andrej@mail.ru>'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # } else { var_dump($opensocket_0); } ?> 

And that's what I got in return:

220 smtp16.mail.ru ESMTP ready 250

smtp16.mail.ru 250 2.0.0 OK 550

not local sender over smtp

I don’t need to know how to send a message from the client to the server, I’m wondering how to send a letter from the server to the server.

    1 answer 1

    The problem is solved, I remembered that I’ve had an old mail server somewhere on my computer, I got it with him, that's what happened:

     <?php header('Content-Type: text/html; charset=utf-8'); # $opensocket_0 = fsockopen('mail.pwon.pp.ua', 25, $errorcode, $errortext); # if ($opensocket_0 !== false) { //echo 'Подключено'; echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'HELO 192.168.1.2'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'MAIL FROM: <htaccess@t.pwon.pp.ua>'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'RCPT TO: <admin@mail.pwon.pp.ua>'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'DATA'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'From: htaccess@t.pwon.. p.ua '."\n".'To: admin@mail.pwon.pp.ua'."\n".'Subject: theme olololo'."\n\n\n"); # fwrite($opensocket_0, 'Hola idioto'."\n"); # fwrite($opensocket_0, "\n"); # fwrite($opensocket_0, '.'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fwrite($opensocket_0, 'QUIT'."\n"); # echo fgets($opensocket_0, 10000)."<br />\n"; # fclose($opensocket_0); } else { var_dump($opensocket_0); } ?> 

    And here is the chat server script with the server:

    220 [192.168.1.2] Courier Mail Server 2.07 ESMTP service ready

    250 [192.168.1.2] greets 192.168.1.2

    250 OK, sender -

    250 OK, recipient -

    354 Send data. End with CRLF.CRLF

    250 OK

    221 Service closing transmission channel