File: headers.py

package info (click to toggle)
pms 0.2.19-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 456 kB
  • ctags: 389
  • sloc: python: 2,655; makefile: 59; sh: 24
file content (30 lines) | stat: -rw-r--r-- 727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os, string, pwd, sys
import PMS

def get_mailname():
	try:
		fp = open('/etc/mailname')
	except (IOError, OSError):
		return get_dnsdomainname()
	try:
		return string.strip(fp.read())
	finally:
		fp.close()

def get_dnsdomaninname():
	if sys.platform[:5] == 'linux':
		command = command + " --fqdn"
	fp = os.popen(command)
	try:
		hostname = string.strip(fp.read())
		dnsdomainname = string.join(string.split(hostname, '.')[1:], 
	                            	'.')
		return dnsdomainname
	finally:
		fp.close()

mailname = get_mailname()

pw = pwd.getpwuid(os.getuid())
print 'From:', string.split(pw[4], ',')[0], '<%s@%s>' % (pw[0], mailname)
print 'X-Mailer: PMS '+PMS.__version__+' (http://pythonms.sourceforge.net)'