Attachments....
Posted: Wed Apr 13, 2005 11:17 am
Hi,
I am using the following code to post a message to a newsgroup....
It works fine but I also need to be able to send binary attachments. Does anyone know how I can modify the code above to do so?
I have looked on the net and all I can come up with are 10 page classes - it must be simpler than that? I can handle the file input part, I just literally need to know how to compose the attachment and send it.
I also tried phpmailer but it does not work for newsgroups with password.
Thanks in advance,
Rob Burne.
I am using the following code to post a message to a newsgroup....
Code: Select all
if ($fp = fsockopen($nntp_host, $nntp_port)) {
// Get the server response
200 == ($resp = fgets($fp, 1024)) or die("Unexpected response: $resp");
// Authenticate
fputs($fp, "AUTHINFO USER $user\r\n");
381 == ($resp = fgets($fp, 1024)) or die("Unexpected response: $resp");
fputs($fp, "AUTHINFO PASS $pass\r\n");
281 == ($resp = fgets($fp, 1024)) or die("Unexpected response: $resp");
// Initiate the message post
fputs($fp, "POST\r\n");
340 == ($resp = fgets($fp, 1024)) or die("Unexpected response: $resp");
// Send the headers
fputs($fp, "From: $from\r\n");
fputs($fp, "Subject: $subject\r\n");
fputs($fp, "Newsgroups: $newsgroups\r\n\r\n");
// Post the message
fputs($fp, "$message\r\n.\r\n");
if (240 == fgets($fp, 1024)){
print "Message posted successfully";
}
fputs($fp, "QUIT\r\n");
fclose($fp);
}
else{
print "Unable to connect";
}I have looked on the net and all I can come up with are 10 page classes - it must be simpler than that? I can handle the file input part, I just literally need to know how to compose the attachment and send it.
I also tried phpmailer but it does not work for newsgroups with password.
Thanks in advance,
Rob Burne.