Fairly simple - for example:
I've a script that runs on my website and lets me know when someone leaves me a comment. So, in my AddComment script, there's
Code:
# Hijack the server's sendmail to send an email
MAIL = "/usr/sbin/sendmail"
# get the email message from a file
f = open('emailtext', 'r')
message = f.read()
f.close()
#Let myself know the updated URL
message = message + "\nhttp://www.cybermenology.com/Comments/" + filename
# open a pipe to the mail program and
# write the data to the pipe
p = os.popen("%s -t" % MAIL, 'w')
p.write(message)
p.close()
#Surprisingly enough, I don't really care what the exit code of the write() is.
#if exitcode:
# print "Exit code: %s" % exitcode
The syntax for opening a system pipe may differ slightly depending on what language you're using. The above is
python.
The actual text file containing the mail headers and the basic message is:
And that's all there is to it.