[GE users] Mail From

benmwebb ben at salilab.org
Fri Mar 27 20:50:05 GMT 2009

jewellc wrote:
> Just a quick question: is it possible to change the From field in mail
> headers sent by SGE?  Currently, mails sent by my SGE installation have
> the From: field set to "root" - something more informative like
> "SGE-cluster" would be better.  Is there an environment variable or
> property that needs setting somewhere?

The easiest way is to write a custom mailer. Run 'qconf -mconf' and
change the mailer field to point to an executable script that wraps the
system mailer and sets the From: field appropriately. I've attached a
Python mailer we use below, which does this. (It also sets the To:
header, since the default for SGE is to try to mail the user at the
submit host, and our submit hosts don't run mail servers.)



from optparse import OptionParser
from email.MIMEText import MIMEText
import subprocess
import sys
import os
import re

# Parse options
parser = OptionParser()
parser.add_option("-s", dest="subject", default='SGE job notification')
opts, recips = parser.parse_args()

# Set email from and to, including any necessary substitutions
email_re = re.compile("@\w+\.cluster\.ourdomain$")
mailto = [email_re.sub("@ourmailhost.ourdomain", x) for x in recips]
mailfrom = 'SGE admin <sge-admin at ourdomain>'

# Create email text
msg = MIMEText(sys.stdin.read())
msg['Subject'] = opts.subject
msg['From'] = mailfrom
msg['To'] = ", ".join(mailto)

# Send email via sendmail binary
p = subprocess.Popen(['/usr/sbin/sendmail', '-oi'] + mailto,

ben at salilab.org                      http://salilab.org/~ben/
"It is a capital mistake to theorize before one has data."
	- Sir Arthur Conan Doyle


To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].

More information about the gridengine-users mailing list