Simple email server tricks
Let's automate email.
We are continually surprised at how many moderately experienced computer users and developers don't know the basic facts about email. Throughout the coming year, we'll explain a few of the essentials and show working scripts that solve common problems.
Automating the original "killer app"
We start with the essentials. Email items travel across the Internet as plain-text byte streams, formatted according to RFC 822 (see Resources, below). This specifies a simple structure of a header followed by content, with a blank line separating the two. A minimal message might then look something like
From someone@somewhere.net Tue Mar 6 16:16:00 2001
This is a message.
Items typically have considerably more elaborate headers, including elements such as To:, From:, Subject:, and so on.
This is enough background to understand one of the questions we come across most often: "How can I automatically send out an email item with a Subject (or Cc, or Bcc, or ...) that says X?" In a typical Unix environment, all it takes is a command line invocation
sendmail -t << END
From: myaccount@myhost.com
Subject: This is the subject.
To: intended_recipient@somewhere.com
Cc: other_person@somewhere.com
Bcc: my_records@myhost.com
Hello. This is the message. Goodbye.
END
You can also emit email messages directly from most languages, without an apparent need to invoke an external process such as the sendmail used here. We use this most often when testing email service, and especially in architecting unusual sites; by coding at a lower level, it's easy to access alternative network ports, request unusual relay topologies, and so on. Through the Resources below, you can locate ways to code email transmissions in such other common scripting languages as KornShell, Perl, Python, Rexx, Ruby, and Tcl.
However, email agents including sendmail add a great deal of value that's not immediately apparent. They will, for example, retry transmissions so that temporary breaks in connectivity don't thwart your attempts to get through. Therefore, our usual advice to developers automating most email operations is just to "shell out" and invoke a specialized, external email agent. All the most popular scripting languages make that easy.
Do you want to attach a file to your outbound message? Many correspondents do. While that takes only a few keystrokes more than a simple message, the concepts behind attachments are widely misunderstood. Let's take a few moments to be clear on the subject.
MIME packages payloads
We've already mentioned that as it travels around the Net from sender to recipient, all email traffic looks the same: header, blank line, body, all expressed
Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.
Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.
Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.







