PHP SMTP server using sockets: connection refused

fpowadorpil

New Member
In one of my personal project I am developing a basic SMTP server in php. It's ready and working when I launch it on its own from the command line; I access it correctly through telnet and it is responding correctly to SMTP commands and I access it correctly also from a php script sending an email using this server.Now I have an issue when I launch the server from a php script and not from the command line (I do it using \[code\]exec\[/code\] function). The server is responding correctly when I access it through telnet but not anymore from a php script sending an email.Could anyone help me?NoteTo send emails from php scripts I use Mail PEAR extension. When I launch the server from within a script and try to send an email in the same process I get this error:\[code\]SMTP: Failed to connect socket: Connection refused (code: -1, response: )\[/code\]SummaryMy server implementation is in \[code\]server.php\[/code\] and the script sending an email is in \[code\]mail-test.php\[/code\].1) If I launch the server on the command line this way: \[code\]php server.php\[/code\] and then launch \[code\]php mail-test.php\[/code\] the script is processed normally and the email is sent. I can also access the server via \[code\]telnet 127.0.0.1 3535\[/code\] and communicating with the server normally.2) Using an another script called \[code\]test.php\[/code\] I wanted to wrap the server management, launching the server via \[code\]exec("php server.php > /dev/null 2>&1 &");\[/code\] and then doing the mail sending from that script in one shot. Doing that way, the server is correctly launched (I can access it via \[code\]telnet\[/code\]) but emails sent from \[code\]test.php\[/code\] thus after the server launch raise an error. If I send emails from an another script before killing the \[code\]test.php\[/code\] process the email is correctly sent however...I hope I am enough explicit.
 
Back
Top