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

Hello Everyone,
I suspect I'm the kind of irritating poster you all cringe at when you see the post. You see, I don’t know perl, however I use a complicated script and I tweak it as much as I can with what little I know. Well, I was informed on a perl newsgroup that the sendmail is "so 90’s" and It isn’t secure. And I should use Mail::sendmail in it’s stead.

I looked at the perl modules installed available to me and I have Mail::Mailer::sendmail and I hope it will do the trick.

However, when I use the following script, I get an error "Undefined subroutine &main::sendmail called at mail.pl line 12." And I fear that maybe it won’t do the trick.

#!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); use Mail::Mailer::sendmail; %mail = ( To => 'me@myisp.com', From => 'info@mywebsite.com', Message => "This is a very short message" ); sendmail(%mail) or die $Mail::Mailer::sendmail::error; print "OK. Log says:\n", $Mail::Mailer::sendmail::log;

My head hurts from googling the last 4 days, trying to figure out how to use Mail::Mailer::sendmail and not having any luck, until now?

Thank you for your advice, Abby

Edited by Chady -- added code tags.

Replies are listed 'Best First'.
Re: Mail::Mailer::sendmail woes
by Belgarion (Chaplain) on May 01, 2004 at 04:47 UTC

    I don't believe there is a Mail::Mailer::sendmail module, but there is Mail::Sendmail, which looks like exactly what you want. (The synopsis even looks like your code.)

Re: Mail::Mailer::sendmail woes
by markov (Scribe) on May 01, 2004 at 10:28 UTC

    Mail::Mailer::sendmail is one of the back-ends for Mail::Mailer, and shouldn't be used directory. A good indication for that is the lower-cased 's' in 'sendmail'.

    When you look at the Mail::Mailer manual page, you see how to use it. You can also use Mail::Send. The general idea is:

    use Mail::Mailer; $mailer = new Mail::Mailer; $mailer = new Mail::Mailer 'sendmail'; $mailer->open(\%headers); print $mailer "This is a very short message"; $mailer->close;
    Mail::Send helps you constructing the headers.
Re: Mail::Mailer::sendmail woes
by b10m (Vicar) on May 01, 2004 at 11:19 UTC
    "I suspect I'm the kind of irritating poster you all cringe at when you see the post (...) I dont know perl, however I use a complicated script and I tweak it as much as I can with what little I know."

    There's nothing wrong with this. I started out doing just that; editing existing scripts. You'll notice that you're gonna understand the code at a certain point if you look at it enough (and mess with it). Then you'll go and add certain pieces of code yourself and before you know it, you write your own scripts!

    It's always nice to have some books laying around though. The O'Reilly Perl books seem popular amongst the Perlmonks (and must say I like them myself).

    "Well, I was informed on a perl newsgroup that the sendmail is "so 90s" and It isnt secure. And I should use Mail::sendmail in its stead."

    I wonder why that was said. If you posted it in some sysadmin group, I could imagine the response. Sendmail is a MTA that can do too much for the average user and if you don't know why Sendmail is better than say Postfix, Exim, etc., chances are you don't need Sendmail (and probably shouldn't). Sendmail is/was known for many security flaws in the past (although it has been pretty quiet lately (or did I miss something? ;)). But that has nothing to do with your scripts, for I take it you aren't the sysadmin. I'm not aware of any security risks in Mail::Mailer::sendmail, but of course, you can turn any script into an insecure piece of work; wheter you use Perl modules or not.

    For emailing there are too many modules and I've seen praise for most of them on Perlmonks somewhere. The "Mail Module preference" can become the new holy flame war topic, like "vi vs. emacs" ;-)

    So, if the code ain't broken, don't fix it, or let some of the guys who claim it's insecure explain to you why this exactly is the case, so you might fix it.

    Just my €0,02

    --
    b10m

    All code is usually tested, but rarely trusted.
Re: Mail::Mailer::sendmail woes
by gmpassos (Priest) on May 01, 2004 at 17:55 UTC
    Mail::SendEasy - Send plain/html e-mails through SMTP servers (platform independent). Supports SMTP authentication and attachments.

    Graciliano M. P.
    "Creativity is the expression of the liberty".

      I did a search on CPAN a while back for modules to send mail with, and I came up with Net::SMTP, but it appears that Mail::Send and Mail::Mailer may be better options as well as your Mail::SendEasy. Any thoughts on why to choose one over the others?
        All the resources in one package.

        Graciliano M. P.
        "Creativity is the expression of the liberty".

Re: Mail::Mailer::sendmail woes
by chanio (Priest) on May 01, 2004 at 05:51 UTC
    Mail::Sendmail is what you need. It is great!

    .{\('v')/}
    _`(___)' __________________________