I'll show you how to make your scripts send you an email
every time they are used.
These instructions are for Unix/Linux servers with sendmail on board.
Make a Backup Copy
Make a backup copy. If something should go wrong
with your edits, you can restore your script with
the backup.
Edit Your Script With a Plain Text Word Processor
Use a plain text word processor to make the edits to your scripts.
NotePad and BBEdit are two plain text word processors. Others are
also available.
WYSIWYG word processors, web page makers, and any program that
generates rich or formatted text, can introduce script-breaking
formatting codes into the file.
Where To Insert the Emailing Code
Insert the emailing code immediately below the first
line of the script that does not start with a hash ("#") character.
Here is the emailing code:
The first, second, and last lines of the above code may be indented.
All other lines must begin at the left margin.
Customizing the Emailing Code
On the first line of the code, modify the directory
path to sendmail (keep the -t) or to qmail for your
server. Keep the vertical bar character as is.
(If you don't know the directory path to your
sendmail, your hosting company's tech support
should be able to tell you. Or, you can use
Master Pre-Installation Tester
to help locate sendmail.)
On the third line of the code, customize the
To: email address. Note that the reverse slash
character must precede the @ character.
The Subject: ... on line four may be customized.
The body content is at lines six through ten.
It may be modified to suit your needs.
Special Identifying Variables
If you would like to insert some identifying
information into the subject or body content,
these are available:
Type $0 (that's a digit zero, not a letter O)
where you want the name of the script to appear.
Type $ENV{HTTP_REFERER} where you want the URL
of the referrer, which would probably be the
URL of the form being used.
Type $ENV{REMOTE_ADDR} where you want the user's
IP address.
Other Customization Considerations
@ symbols must be escaped with a backward-slash:
Unless they're used as the first character of a
variable name (like the special identifying variables
above), $ symbols must be escaped with a
backward-slash.
Giving the Email Cc, and Bcc Destinations
Header lines Cc:, and/or Bcc: may be
specified. Put them below the line beginning with
"print" and above the first blank line. Between the
To: and Subject: header lines would be good.
(A From: header line may also be specified in the same manner.)
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]