Matt Doughty wrote:
On Wed, Mar 09, 2005 at 09:42:00AM -0800, Ted Zeng wrote:

Hi,

When  I used perl on Windows, I used Mail:sender module to send emails,
with attachments.

Now I realized that Mac OS X doesn't have this installed (I installed it on Windows myself)
and it has sendmail as a UNIX tool, which can be an option.


My question is:
Do you use sendmail to send emails in your perl tools?
Or use a Perl email module to send emails? Which way you prefer?



So you have heard one position on this subject. I'll give you the other. Using the command line sendmail client gives you queueing if the SMTP server you are talking to is down, or temporarily unreachable. I'm not certain if there is a module out there that will use the sendmail command line client directly, but this is definitely the way to go if you don't want to lose mail, and you don't want to worry about queueing yourself.

--Matt



Ok, so backing up a step. The key here is that there are two steps to the process.


1. Build the message (probably in memory)
2. Send the message

For #1 you absolutely want to use a module. Period. There are far, far, far too many intricacies of the message format protocol to try to do this by hand. And you *don't* want to rely on the log messages of any smtp client/server to find problems in your message building. And the minute you get into including attachments, you have really screwed yourself. Take a look at the documentation and structure of Mail::Box if you think e-mail done right is easy. The module maybe overkill for a lot of applications, but it is about as thorough as you can get. There are many modules that will build a correct message.

For #2 it matters less. Because #1 and #2 are usually intertwined most modules that provide #1 will provide #2 too. And because talking to sendmail at the command line can get very hairy very quickly you are still better off letting a module do it. The interface has been designed for ease of use, the module has (hopefully) been tested, possibly on many platforms, and most provide an option to set which local mail client/server you wish to talk to. So most can handle #2 using postfix, sendmail, etc. Net::SMTP is probably one of the ones that can't, but then you wouldn't want to build a message with it anyways.

I spent 2 years working on an application that 90% of the time was dealing with mail inbound or out, you need to be an absolute expert in mail handling (which I am not by a long stretch!) to do so directly.

http://danconia.org

Reply via email to