There are a few important issues. The most widely used approach is starting a sendmail process and piping the headers and the body to it. If you don't want your process to wait until delivery is complete, you can tell sendmail not to deliver the email straight away, but either do it in the background or just queue the job until the next queue run.
Some people prefer using lighter mail delivery programs like qmail .
The most efficient approach is to talk directly to the SMTP server. Here is an example of a subroutine that sends email. Download Written by Stas Bekman .