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

Is there a PPM install for sendmail by any chance? How hard is it to send mails via Perl if you don't have a server (and not using a webhost with CGI)?

Replies are listed 'Best First'.
Re: perl sendmail install
by mrborisguy (Hermit) on May 29, 2005 at 00:51 UTC

    If you have an SMTP account, you could look into Net::SMTP, which has worked nicely for me many times.

        -Bryan

Re: perl sendmail install
by tchatzi (Acolyte) on May 29, 2005 at 11:56 UTC
    There is a module which you can send mail with and its realy easy to use. You can find documentation here -> Mail::Sender
    #!/usr/bin/perl -w use strict; use Mail::Sender; #create mail and send attached a file if you want $sender = new Mail::Sender{ smtp => 'smtp_server_of_your_mail', from => 'my_name@whatever.com' }; $sender->MailFile({ to => 'name@whatever.com', subject => 'Hello....', msg => "The attached file i've been trying to send....hmmm" +, file => 'my_file.foo' }); $sender->Close();

    To install it, with ppm just
    ppm> install Mail-Sendmail
    You can also search for sendmail at cpan or just mail

    ``The wise man doesn't give the right answers, he poses the right questions.'' TIMTOWTDI
Re: perl sendmail install
by monarch (Priest) on May 29, 2005 at 12:55 UTC
    I'm just scratching my head on this one...

    Mail is not something to mess around with.. as the world can attest to with the gobs of spam floating around the world. That being said, it is expected that if you're going to play with sending mails yourself you should know what you're doing.

    Perl has ActiveState PPMs for the Mail::Sendmail module, and you can find these at http://search.cpan.org/~mivkovic/Mail-Sendmail-0.79/Sendmail.pm (search cpan for Mail::Sendmail).

    Mail::Sendmail is a great simple module for sending your email to a SMTP server, and you will almost certainly have access to one with your ISP account wherever that is. IE if your isp is myinternet.com, then odds are you can send your mail to smtp.myinternet.com, which will take care of forwarding your email appropriately to the destination SMTP server.

    Bypassing this process and performing the mail agent operation yourself is a risky and difficult process, something recommended for the experts. I have played with sendmail and believe me it's not a simple job.

    I know I'm not being helpful here, but I recommend you become a guru in SMTP and mail in general before getting Perl involved in such advanced tricks..

Re: perl sendmail install
by TedPride (Priest) on May 29, 2005 at 19:12 UTC
    There are free mail servers available for any OS you can think of, and the modules specified above will interface well with them. The main problem is not sending emails, but rather preventing them from being filtered out at their destination. A lot of hosts reject emails that come from a dynamically assigned domain name / IP. If you're going to be doing a lot of mailings (and I hope they're legit, not spam), you'll need a static IP with a domain name pointing to it, that you can reference in your From / Return-Path header fields and that the target host can verify using reverse lookup.