tcp send
Posted: Mon Aug 04, 2008 8:19 am
I have tried to do a tcp send in autoit, http://www.autoitscript.com script but can't get it to function.
I have been told to do it in php, so i will try.
I will have to connect to a specific ip-adress, and a specific port, then send data by a socket connection, how do i do this?.
I have installed notepad++ and found some code to begin coding, but how do i execute the code? I want the php program to be executed as a standalone exe.
<?php
$handle = fsockopen('mail.uplinklounge.com', 25, $erno, $errstr, 30);
if (!$handle) {
//if connection fails exit and tell us what went wrong.
die("Connect failed: $errstr\n");
}
else {
$message = "MAIL FROM: iadnah@uplinklounge.com\r\n".
"RCPT TO: test@uplinklounge.com\r\n".
"data\r\n".
"Subject: this is a test\r\n".
"This is the contents of a mail\r\n".
".\r\n";
//read the first line the smtp server gives us (usually the version string)
$responses = fgets($handle, 1024);
//send our data to the smtp server
fwrite($handle, "$message");
/*
until there is no more output to read from the smtp server keep storing all the output
in the $responses variable. Once there's nothing else to read show us all the output
and exit
*/
while (!feof($handle)) {
$responses .= fgets($handle, 1024);
}
echo "$responses";
fclose($handle);
}
?>
I have been told to do it in php, so i will try.
I will have to connect to a specific ip-adress, and a specific port, then send data by a socket connection, how do i do this?.
I have installed notepad++ and found some code to begin coding, but how do i execute the code? I want the php program to be executed as a standalone exe.
<?php
$handle = fsockopen('mail.uplinklounge.com', 25, $erno, $errstr, 30);
if (!$handle) {
//if connection fails exit and tell us what went wrong.
die("Connect failed: $errstr\n");
}
else {
$message = "MAIL FROM: iadnah@uplinklounge.com\r\n".
"RCPT TO: test@uplinklounge.com\r\n".
"data\r\n".
"Subject: this is a test\r\n".
"This is the contents of a mail\r\n".
".\r\n";
//read the first line the smtp server gives us (usually the version string)
$responses = fgets($handle, 1024);
//send our data to the smtp server
fwrite($handle, "$message");
/*
until there is no more output to read from the smtp server keep storing all the output
in the $responses variable. Once there's nothing else to read show us all the output
and exit
*/
while (!feof($handle)) {
$responses .= fgets($handle, 1024);
}
echo "$responses";
fclose($handle);
}
?>