Am Donnerstag, den 10.09.2009, 10:18 -0400 schrieb Wietse Venema:
[...]
> This is an output buffering problem. You need to flush output
> after each reply, perhaps by calling the flush() function.
> 

Hy!

No, I am afraid that this is not the problem.

I am sendig you a few details of my setup

Here is my php script test.php:
<?php
error_reporting(E_ALL);
fprintf(STDOUT, "220 localhost SMTP foo test\n");
fflush(STDOUT);
fprintf($log, "Sent opening string (220 localhost SMTP ...)\n");
fprintf(STDOUT, "250 Hello client.example.org, nice to meet you\n");
fflush(STDOUT);
flush();
fprintf(STDOUT, "250 Sender OK\n");
fflush(STDOUT);
flush();
fprintf(STDOUT, "250 Recipient OK\n");
fflush(STDOUT);
flush();
fprintf(STDOUT, "354 End data with <CR><LF>.<CR><LF>\n");
fflush(STDOUT);
flush();
fprintf(STDOUT, "250 Message accepted for delivery\n");
fflush(STDOUT);
flush();
fprintf(STDOUT, "221 See you later\n");
fflush(STDOUT);
flush();
exit(0);
?>

which is activated in master.cf by

127.0.0.1:10025 inet n  n       n       -       20      spawn
    user=nobody argv=/tmp/test.php

(yes, I tried a different user as well)

I am testing this setup with a simple perl script
#!/usr/bin/perl

use strict;
use Net::SMTP;

my $smtp = Net::SMTP->new('localhost:10025', Debug => 1);
exit 0;

which fails and does not receive any input data.
Here is the output of "tcpdump -nA -i any port 10025" upon calling this
smtp client:
tcpdump: WARNING: Promiscuous mode not supported on the "any" device
tcpdump: verbose output suppressed, use -v or -vv for full protocol
decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 96
bytes
10:11:34.917815 IP 127.0.0.1.42745 > 127.0.0.1.10025: S
1684489309:1684489309(0) win 32767 <mss 16396,sackOK,timestamp
1853261109 0,nop,wscale 2>
E..<....@.@.{Q..........')dgd]........%.....@....
nv.5........
10:11:34.917864 IP 127.0.0.1.10025 > 127.0.0.1.42745: S
1696242199:1696242199(0) ack 1684489310 win 32767 <mss
16396,sackOK,timestamp 1853261109 1853261109,nop,wscale 2>
E..<....@.@.<.........')..e...dgD^....2)....@....
nv.5nv.5....
10:11:34.917897 IP 127.0.0.1.42745 > 127.0.0.1.10025: . ack 1 win 8192
<nop,nop,timestamp 1853261109 1853261109>
e.....@.@.{X..........')dgD^e..... ..G.....
nv.5nv.5
10:11:34.957172 IP 127.0.0.1.10025 > 127.0.0.1.42745: P 1:2(1) ack 1 win
8192 <nop,nop,timestamp 1853261119 1853261109>
e.....@.@...........')..e...dgD^.. ..).....
nv.?nv.5

10:11:34.957228 IP 127.0.0.1.42745 > 127.0.0.1.10025: . ack 2 win 8192
<nop,nop,timestamp 1853261119 1853261119>
e.....@.@.{W..........')dgD^e..... ..2.....
nv.?nv.?
10:11:34.958317 IP 127.0.0.1.42745 > 127.0.0.1.10025: F 1:1(0) ack 2 win
8192 <nop,nop,timestamp 1853261119 1853261119>
e.....@.@.{V..........')dgD^e..... ..1.....
nv.?nv.?
10:11:34.961625 IP 127.0.0.1.10025 > 127.0.0.1.42745: P 2:30(28) ack 2
win 8192 <nop,nop,timestamp 1853261120 1853261119>
e.....@.@..x........')..e...dgD_.. ..D.....
n...@nv.?220 localhost SMTP foo test

10:11:34.961686 IP 127.0.0.1.42745 > 127.0.0.1.10025: R
1684489311:1684489311(0) win 0
E..(....@.@.<...........')dgD_....P...:...

Which means, that at least the opening string is somehow sent to client,
but obviously not in a correct way.

If I substitute the php script with a simple c++ programm:
#include <iostream>
#include <fstream>

using std::endl;
using std::cout;

int main(int argc, char** argv)
{
  cout<<"220 localhost SMTP foo test"<<endl;
  cout <<"250 Hello client.example.org, nice to meet you"<<endl;
  cout <<"250 Sender OK"<<endl;
  cout <<"250 Recipient OK"<<endl;
  cout <<"354 End data with <CR><LF>.<CR><LF>"<<endl;
  cout <<"250 Message accepted for delivery"<<endl;
  cout <<"221 See you later"<<endl;
  return 0;
}
everything works fine.

Well, I hope you can find any flaws in this setup to save my day ...

cheers
Mathias

Reply via email to