Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

e-mail question

by Prince99 (Scribe)
on May 01, 2001 at 17:02 UTC ( #76932=perlquestion: print w/replies, xml ) Need Help??

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

Hello fellow Monks,
I have a question and I need your help. We have 4 different servers at work and our mail system only runs on one of them. For the Intranet pages I am developing, they would like a suggestion page where all the suggestions get e-mailed to the head of HR. The web server doesn't run on the mail server. Therefore I have the choice of setting up mail on the web server or using my script to login to the mail server and then send the mail. I don't have a problem logging on to the other server, but I have know idea how to set it up to automatically e-mail. I would just use a Mailto: link in my html code, but we use ?PINE? for mail because we were getting to many virus's with other e-mail programs like Outlook Express. Has anyone dealt with a similiar problem. Any help on what to do or where to look would be appreciated. Sorry no real code examples, but like I said I have no idea where to start on the mail part.

Prince99

Too Much is never enough...

Replies are listed 'Best First'.
Re: e-mail question
by jeroenes (Priest) on May 01, 2001 at 17:13 UTC
    Several ways to go:

    1. Install mail+sendmail on the box and go from there.

    2. Use MailTools in combo with Net::SMTP.

    CPAN is your friend!

    Jeroen
    "We are not alone"(FZ)

Re: e-mail question
by Aighearach (Initiate) on May 01, 2001 at 17:13 UTC
    I use Mail::Sendmail, it makes it as simple as creating one hash and making one function call.
Re: (Zigster) e-mail question
by zigster (Hermit) on May 01, 2001 at 18:23 UTC
    You have to take the place of pine sending your mail to a place that can handle it. The simplest way to do this is to locate the SMTP server on your network. Look in pines configuration it will point to a machine that exposes port 25. This machine will know how to route mail. It will expect connections from a variety of mail clients. You then use a perl module such as net::smtp as shown below.
    use Net::SMTP; my $from='foo@spangle.com'; my $to='someuser@host.com'; my $smtp= Net::SMTP->new('SMTPHOSTNAME', Timeout => 180); $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend("YOUR MESSAGE"); $smtp->dataend(); $smtp->quit();
    There is no reason to set mail up on the web server, as long as it can see a machine that can route the mail. If the webserver is in your DMZ and cannot see your internal SMTP server speak to your sysadmin and find out where the next hop is. Your local SMTP server will have to route all its mail out to another SMTP server to do the delivery. Unless you work for a v large company it is unlikely you do local mail routing. This second hop SMTP server will most likely be hosted within your ISP. --

    Zigster
Re: e-mail question
by AidanLee (Chaplain) on May 01, 2001 at 17:09 UTC

    Well, AFAIK pine is simply a mail client, not a mail server. I would reccommend finding out what mail server you run and looking up to see if it will take input directly from the command line (much as sendmail does).

    If it does not you could probably find the base code for a POP3 or SMTP client on CPAN which you could install on your web server, making it just another client as far as the server is concerned

Re: e-mail question
by Prince99 (Scribe) on May 01, 2001 at 17:27 UTC
    Thanks fellow monks for giving me a place to start. I know it seemed like a trivial question, but those are very hard for newbies. I appreciate you taking you most important time to answer.

    Prince99

    Too Much is never enough...
Re: e-mail question
by murphya (Sexton) on May 01, 2001 at 17:27 UTC
    I have been doing something similar and Mail::Sendmail is definitely the way to go.

    It is very easy to set up - just change one line in the module to define you mail server.

    It is then a simple matter to sort the data and produce a reasonably professional looking e-mail notification.

Re: e-mail question
by le (Friar) on May 01, 2001 at 17:18 UTC
    If I get your message right, then create something like a formmailer. Set up a HTML form where people fill in their suggestions, pass the values to a CGI script, that finally sends the mail. With CGI.pm and Mail::Sendmail it shouldn't be too hard, Mail::Sendmail lets you send via an SMTP server other than the one your script is running on.
Re: e-mail question
by coreolyn (Parson) on May 01, 2001 at 22:52 UTC

    If you're in a DMZ that can't see mail (port 25 closed to traffic) you may want to consider setting up Net::SMTP::Server::Relay on a non blocked port on a system outside of your DMZ to relay your mail. Then in your webapp just use Mail::Sendmail and point it to the relay.

    #! /home/perl/5.6.0/bin/perl -w # File: minimail.pl # A mail relayer use strict; use Net::SMTP::Server; use Net::SMTP::Server::Client; use Net::SMTP::Server::Relay; my($conn,$client); #NOTE: the use of port number 2525 my $server = new Net::SMTP::Server("xxx.xxx.xxx.xxx", 2525); while($conn = $server->accept()) { my $client = new Net::SMTP::Server::Client($conn) || croak("Unable to handle client connection: $!\n"); $client->process || next; # Log for debugging # open LOG, ">./mini.log"; # print LOG "We hit!\n From->$client->{FROM}\nTO->$client->{TO}\nMSG-> +$client->{MSG}\n"; # close LOG; my $relay = new Net::SMTP::Server::Relay($client->{FROM}, $client->{TO}, $client->{MSG}); }
    coreolyn
Re: e-mail question
by alfie (Pilgrim) on May 02, 2001 at 11:58 UTC
    One more think you'd like to try, for you mentioned pine:
    You want to call pine when someone clicks on a mailto: link in your page? There is a chance for them to get that done. The package you are searching for is muttzilla. Although it's called muttzilla it is simply a plugin for netscape that calls any program you like. You need to change the users preferences.js in their ~/.netscape directory, though. But it might be something many are interested :)
    --
    use signature; signature(" So long\nAlfie");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://76932]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-06-27 15:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (88 votes). Check out past polls.

    Notices?