|
The ability to send mail via JavaScript can make your site truly dynamic. Today we'll explore the JavaScript methods to get your message out.
|
Server Side JavaScript Mail Sending
Yet another cool feature of server side JavaScript is the
ability to send mail via scripted actions. There is a huge
amount of possibilities that will enhance your web site when
you realize what you can do with script-generated email.
Your site can become truly dynamic. Sending a custom email
to your users greatly enhances their perception of your
site, thus increasing traffic flow and your ever-important
online reputation. You would use an instance of the SendMail
server side JavaScript object. The use of this object is
very simple and straightforward, the common methods and
properties of which are listed below. Most are very
intuitive if you've ever worked with email before. By now
you should be able to spot a method as opposed to a property
(yes?).
- Bcc - Blind Carbon Copy. This is the list of users to
which you want to send a blind carbon copy of the
email.
- Body - This is used to contain the text of the email,
the "body" of the document.
- Cc - Carbon Copy. This is the list of users to which you
want to send a carbon copy of the email.
- ErrorsTo - This is used to provide an email address
which errors will be sent to.
- From - This is used to specify the sender's email
address.
- Organization - This is used to provide the company or
organization name from which the email was sent.
- ReplyTo - This is used to provide the reply address of
the email.
- Smtpserver - This is used to provide the address (IP or
HostName) of the mail server which will send the
message.
- Subject - This is used to provide the subject of the
email.
- To - This is used to provide the email address the email
is to be sent to.
- errorCode() - This is used to return a numbered error,
if one occurs during the sending of email.
- errorMessage() - This is used to return a verbose error,
if one occurs during the sending of email.
- send() - This is used to actually send the email.
From the above list of options, you might realize that
you can use a database to send out bulk mail to all of the
users of your site, or within your organization. Using the
send mail feature inherent to server side JavaScript negates
the need for those pesky, slow, and bulky PERL scripts
sometimes used to send mail. Also, since the server side
script is compiled down to its byte code format, the sending
of bulk mail to many users is fairly quick. This is a great
advantage of using your script in a lightening quick
compiled format.
Using server side mail also reduces the workload for the
web master. In using pertinent client side JavaScript,
e-mails can be verified and rejected if an e-mail address is
not valid. Subject lines may also be verified - there is
nothing worse to a web master than having several hundred
(or even thousand!!) emails in your inbox with no subjects.
Most simply delete them without hesitation (or remorse).
Stop by next week where we'll take a look at the JavaScript
File Object and some basic file manipulation.
Database Connectivity via Server Side
The JavaScript Chronicles
Server Side JavaScript and File Manipulation
The JavaScript Chronicles
JavaScript Introduction
Part 2: Data Types
Part 3: Arrays
Part 4: Operators
Part 5: Conditional Statements
Part 6: JavaScript Functions
Part 7: Pattern Matching - The RegExp Object
Part 8: Introduction to Server Side JavaScript
Part 9: Server Side JavaScript Mail Sending
Part 10: Server Side JavaScript and File Manipulation
Part 11: Working with Forms in JavaScript
Part 12: Getting to Know Dynamic HTML
|