Created
March 22, 2011 17:59
-
-
Save kryali/881683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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