in reply to Questions about sending e-mails

When I use email related perl modules, do I need to care about operation systems?

There are differences between operating systems and these may affect you, depending on what you are doing and how you do it. You can read perlport for some initial guidance on portability and you should also read the platform specific documentation for your platforms of interest and release of perl. You can find the former from perl. The latter depends on your release - review your documentation to find it.

Many of the email related modules are quite independent of platform but not all of them. Even if the modules are platform independent your code may not be. It is best to be careful and well informed about this issue if you want to write portable code. You may want to use only pure Perl modules that don't execute other programs on your system. Otherwise, and no matter what you do, you will have to test your application at some point. Plan thorough tests, test early and test often. Don't do all your development on one platform before testing on your alternate platforms.

Do I need to think about whether or not I have an email server in my system?

If you want to exchange email with other systems (you probably do) then you will have to think about mail servers. Some perl modules may try to access local mail related software (e.g. sendmail on *nix platforms) or other resources that differ from platform to platform (e.g. mailboxes). You will have to consider the availability of mail servers, how you will use them and how they are configured to support your application. You will likely want some mail server to relay messages for you and configuration of the mail server will probably be necessary to allow this. You will also have to decide what you will do if a mail server is not available at the time you wish to access it. A local mail server may be more available than a remote one. In many cases I have installed a local mail server for this reason and to let the local mail server handle queueing and routing of messages.

I create and test my perl/cgi based web application on my Windows laptop and then port it to the external web host, like I guess many do. So I would prefer to have an email module which:

1) works on windows, unix and linux platforms without thinking about email server, etc.

When you stop thinking, your risk of unpleasant surprises increases dramatically.

2) since I want an easy way of transfering my application from my laptop to the webhost I would prefer to use the module that can be put to my local lib together with all my subs.

I don't understand what you are saying here. Sorry...

Replies are listed 'Best First'.
Re^2: Questions about sending e-mails
by vit (Friar) on Mar 19, 2009 at 18:23 UTC
    Thanks a lot for your detailed response.

    /* since I want an easy way of transfering my application from my laptop to the webhost I would prefer to use the module that can be put to my local lib together with all my subs. */

    I mean I would prefer to place the module to my local application lib, not to perl/lib so that I could upload it as it is to the webhost.

    /* If you want to exchange email with other systems (you probably do) */

    all I need to do with emails in my application is to send a confirmation message to a given address. I do not need attachements.

      You can install any module (or at least the vast majority, I suppose there might be some with hard-coded path nonsense) anywhere you like.

      Installation is often more than just copying files. Some modules check for dependencies, compile and link code and configure themselves at installation. If you just copy the installed files you skip all these steps. If you are moving to a different platform this is more likely to be a problem.

      You can gain some insight into what the issues might be for a particular module by looking at how it is built and installed. If all that is done is copy .pm files into place, then you can just copy the files yourself. If more is done you will have to think carefully about the implications of skipping those steps when you copy the files yourself.

      What goes in the message is one thing. How you deliver it is another. If the body of the message is plain text, preparing it is easy. You still need to send it, either to a local or remote mail server, unless you are writing it directly to a local mailbox. There are perl modules that deliver via SMTP protocol without use of an external program.

      I have used Net::SMTP for simple cases in the past but there are many others. A search of CPAN for smtp yields many results.