Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

php smtp server for receiving incoming mail

the mail() function

Moderators: macek, egami, gesf

php smtp server for receiving incoming mail

Postby vector » Tue Oct 23, 2012 1:34 pm

i actually have this working, all the way up to the handshake and the close of the connection. the problem is, it only works over telnet, and not with mail sent via sendmail nor gmail.

here's the setup:

# the script is running as a SERVICE on port 25, and i launched it from the terminal so i can see its echos (so i know what it's doing)

# the firewall is open to the internet

# i telnet into the public ip on port 25 via "telnet example.com 25", using another open terminal, and i can do a full smtp session, and view output in the client side, and view server side echos in the server's terminal

# i use "sendmail -t user@example.com <n>blah blah!<n>.<n>" and sendmail seems to accept it, but the server side terminal does not respond in any way

# i use gmail to send an email, and the server side terminal has no output


so, i'm stumped as to why it APPEARS that mail transfer agents are not reaching my smtp service, and yet its just fine with telnet. it would output SOMETHING to show at least a connection was made, but i get nothing.


here's a snippet of my code:

Code: Select all
<?// if ($socket = socket_create_listen(25)){

if ($socket = socket_create(AF_INET , SOCK_STREAM , SOL_TCP)){
   //socket_set_option($socket , SOL_SOCKET , SO_REUSEADDR , 1);
   echo "TCP Socket Created\n";

   if (socket_bind($socket , '0.0.0.0' , 25)){
      echo "TCP Socket Bound\n";
      socket_listen($socket);
      //socket_set_nonblock($socket);

      while(true){
         if($connection = socket_accept($socket)){
            echo "\n================================BEGIN================================\n";
...
         }
      }
   }else{
      echo "tcp Socket Failed to bind\n";
   }
}else{
   echo "tcp Socket Failed to Create\n";
}


thanks in advance
vector
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Oct 23, 2012 1:25 pm

Re: php smtp server for receiving incoming mail

Postby vector » Wed Oct 24, 2012 2:39 am

the problem was sendmail - or the lack therof.

i had postfix installed, and stopped it from running so that i could play with my php mail server prototype. well, i forgot, there's "sendmail" the PACKAGE (linux), and then there's "sendmail" the POSTFIX wrapper module which emulates sendmail (so that you don't have to have sendmail running, which would interfere with postfix), and since posftix wasn't running, it wasn't SENDING. so, installing the sendmail package fixed that problem.

the other problem still persists - where i still can't send a mail from the web. however, since it works locally, and my firewall is disabled, and my router's portforwarding is correct, i think it's safe to assume that's just a DNS error, which i'll take care of later.
vector
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Oct 23, 2012 1:25 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.