Hello, Im having trouble using fsockopen and fputs to send email through an smtp server. I tried manually issueing the commands and it works great through telenet, but when i try to do the same with a php script I get this.
220 csun.edu Microsoft ESMTP MAIL Service, Version: 6.0.3790.0 ready at Tue, 25 Nov 2003 14:25:44 -0800
15
250-csun.edu Hello [130.166.1.1]
30
250-TURN
31
250-SIZE 2097152
6
250-ETRN
21
250-PIPELINING
3
6
250-DSN
I dont know what the TURn,ETRN, DSN and PIPELINING messages are.
This is the code that yielded the above result
<?php
$fp = fsockopen ("130.166.1.1", 25);
echo fgets ($fp,128);
echo "<br>";
echo fputs($fp, "EHLO csun.edu\r\n");
echo "<br>";
echo fgets ($fp,128);
echo "<br>";
echo fputs($fp, "MAIL FROM:<sender@csun.edu>\r\n");
echo "<br>";
echo fgets ($fp,128);
echo "<br>";
echo fputs($fp, "RCPT TO:<reciever@csun.edu>\r\n");
echo "<br>";
echo fgets ($fp,128);
echo "<br>";
echo fputs($fp, "DATA\r\n");
echo "<br>";
echo fgets ($fp,128);
echo "<br>";
echo fputs($fp, "This is the letter\r\n");
echo "<br>";
echo fgets ($fp,128);
echo "<br>";
echo fputs($fp, ".\r\n");
echo "<br>";
echo fputs($fp, "QUIT\r\n");
echo "<br>";
echo fgets ($fp,128);
echo "<br>";
fclose ($fp);
?>
I issued the same commands by telenetting into the server and it worked fine. Any suggestions or input would be greatly appreciated. I have tried searching google for what TURN, and PIPELINING mean but havent found anything that helps. Thanks.
Edit-
Thought it might be helpful if i added what i type when i telnet into the server.
Telnet 130.166.1.1 25
HELO blah
MAIL FROM: sender@csun.edu
RCPT TO: receiver@csun.edu
DATA
This is a message
.
QUIT
and it all works fine and i get the email at receiver@csun.edu