Article View: pl.comp.lang.perl
Article #717Re: prosty mailer
From: Adam Glowacki
Date: Sun, 23 Nov 1997 15:54
Date: Sun, 23 Nov 1997 15:54
50 lines
2234 bytes
2234 bytes
Piotr Piatkowski wrote:
>
> sub send_mail {
> my( $from, $to, $subject, $body ) = @_;
> open( SM, "|/usr/sbin/sendmail -f$from $to" )
> or die "open sendmail: $!";
> print SM "From: $from\n";
> print SM "To: $to\n";
> print SM "Subject: $subject\n";
> print SM "Mime-version: 1.0\n";
> print SM "Content-type: text/plain; charset=ISO-8859-2\n";
> print SM "Content-transfer-encoding: 8bit\n";
> print SM "\n";
Az do tego miejsca zamiast LF chyba musi byc CRLF.
> print SM "$body";
> close SM
> or die "close sendmail: $!";
> }
>
Ja bym proponowal wpisanie listu do zmiennej i wywolanie programu
sendmail
w nastepujacy sposob (sciezki zaleznie od systemu):
system( "/usr/lib/sendmail -t <$tresc_listu" );
gdzie $tresc_listu:
From: xxxxx\r\n
To: xxxxx\r\n
Subject: xxx\r\n
\r\n
bla bla\n
bla bla\n
W zasadzie pole From: okresla sie jako parametr -f sendmaila, ale
sendmail czyta je tez z naglowka (testowalem na SunOS, Solaris i IRIX).
W przypadku CGI nalezy unikac podawania adresu odbiorcy bezposrednio
w funkcji open. Zlosliwy internauta poda jako swoj e-mail np.
jasio@xyz.pl < `cat /etc/passwd`
badz podobnie i shell to wykona. Oczywiscie mozna sprawdzac
poprawnosc adresow e-mail, ale powyzsza metoda jest chyba wygodniejsza.
>Acha - jak siê u¿yje tego bez roota, to chyba sendmail dopisuje
>jakie¶ ostrze¿enie do nag³ówków, ¿e nieautoryzowane u¿ycie opcji -f,
>czy co¶ takiego...
Jesli pole From: jest podane w naglowku, to system u mnie nic nie
dopisuje.
adam
Technical Details
Message-ID:
<347851BE.7F82@baunet.de>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!uw.edu.pl!news.icm.edu.pl!news.nask.pl!usenetReferences:
<65428n$qmf$1@galaxy.uci.agh.edu.pl> <Pine.LNX.3.95.971122212102.3318B-200000@wizard.ae.krakow.pl> <6586sr$ctm$1@galaxy.uci.agh.edu.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!uw.edu.pl!news.icm.edu.pl!news.nask.pl!usenet From: Adam Glowacki <webmaster@baunet.de> Newsgroups: pl.comp.lang.perl Subject: Re: prosty mailer Date: Sun, 23 Nov 1997 16:54:38 +0100 Organization: BauNet GmbH Lines: 50 Message-ID: <347851BE.7F82@baunet.de> References: <65428n$qmf$1@galaxy.uci.agh.edu.pl> <Pine.LNX.3.95.971122212102.3318B-200000@wizard.ae.krakow.pl> <6586sr$ctm$1@galaxy.uci.agh.edu.pl> Reply-To: webmaster@baunet.de NNTP-Posting-Host: 149.205.212.2 Mime-Version: 1.0 X-Mailer: Mozilla 3.01 (WinNT; I) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit