Skip to content

Instantly share code, notes, and snippets.

@kryali
Created March 22, 2011 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kryali/881683 to your computer and use it in GitHub Desktop.
Save kryali/881683 to your computer and use it in GitHub Desktop.
from nntplib import NNTP
import time
def message(subject, group, author, body):
header = ''
header += "Subject: " + subject
header += "\nFrom: " + author
header += "\nNewsgroups: " + group
t = time.strftime('%d %b %Y %H:%M:%S %Z')
header += "\nDate: " + t
header += "\nUser-Agent: [CourseOverflow]\n\n"
header += body
return header
netid = #your netid
password = #your ad password
s = NNTP('localhost', 110, netid, password )
article = message("[CourseOverflow] Python posting test",·
"cs.test",·
"Kiran Ryali <kiran.ryali@gmail.com>",·
"This is an automated test message")
print article
f = open('article', 'w')
f.write(article)
f.close()
f = open('article', 'r')
s.post(f)
s.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment