Gerard has asked for the wisdom of the Perl Monks concerning the following question:

I am rewriting a script for my new job, primarily because the guy that wrote it does not use cgi but rather some sort of home rolled version.
This may not be a strictly perl question but I have looked around on google etc. but to no avail and know nowhere else to turn....
`postmail -H domain.com -t $Owner_email < $filename`; $mailerror = $?;
Is the code in the existing script that sends out the email. I only have ftp access to the server, but do know that it is a Win 2k server.
I would rather write emails similarly to the way in which I use sendmail, but do not know if this is possible. ie. I would rather not write everything to a file and then email that, and then delete the file, as is the case with the existing script.
Has any one had any experience using postmail.
Any comments or suggestion would be useful, because I know nothing about it

Replies are listed 'Best First'.
Re: `postmail
by grinder (Bishop) on May 28, 2002 at 22:04 UTC
    Numerous pure-Perl solutions exist for sending email. The one I am most familiar with is Mail::Sendmail. You should be able to edit the defaults to something sensible, and ftp the module (Sendmail.pm) to what will probably be the c:/perl/lib/site_perl/Mail directory. I suspect the site_perl directory will exist, but you might have to mkdir the Mail subdirectory.

    Once you get that far, the main trick will be to build up the body of the message by concatenating to a string, and then doing something like:

    my %mail; $mail{'From'} = 'me@example.com'; $mail{'To'} = 'you@example.com'; $mail{'Subject'} = 'The moon is blue'; $mail{'Body'} = $some_humongous_string; sendmail( %mail ) or warn "sendmail error: $Mail::Sendmail::error\n" +;

    An alternative is to use Net::SMTP, which has a number of fans around here. I've used it a couple of times with satisfactory results.

    In any event, you should be able to drag postmail to the recycle bin in short order!


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
      Thanks for your comments. I do not really want to send the emails via an SMTP server, which I believe this is what these modules do? Correct me if I am wrong. From what I can gather postmail is some sort of old mail delivery agent, similar to sendmail? Is this correct? Regards, Gerard