hweefarn has asked for the wisdom of the Perl Monks concerning the following question:
hi everybody :)
recently i am learning about perl socket programming. i found a tutorial and sample about using perl to send email (through socket). i try to run that script but not successful. then i try to debug it but there are something that i dont understand. so i decide to ask you all :)
here is part of the sample code that i dont understand:
use Socket; use strict; my($mailTo) = 'me@here'; my($mailServer) = 'host.there'; my($mailFrom) = 'me@here'; my($realName) = "Ralph Martin"; my($subject) = 'Test'; my($body) = "Test Line One.\nTest Line Two.\n"; $main::SIG{'INT'} = 'closeSocket'; my($proto) = getprotobyname("tcp") || 6; my($port) = getservbyname("SMTP", "tcp") || 25; my($serverAddr) = (gethostbyname($mailServer))[4]; if (! defined($length)) { die('gethostbyname failed.'); } socket(SMTP, AF_INET(), SOCK_STREAM(), $proto) or die("socket: $!"); $packFormat = 'S n a4 x8'; # Windows 95, SunOs 4.1+ #$packFormat = 'S n c4 x8'; # SunOs 5.4+ (Solaris 2) connect(SMTP, pack($packFormat, AF_INET(), $port, $serverAddr)) or die("connect: $!");
i dont understand about $mailserver, $proto, $port, $serverAddr and $packFormat.
the explaination that i get from the web are as below, but i'm still abit confused.
20031220 Edit by Corion: Changed formatted code to CODE tags
20031221 Edit by jeffa: Aliased email addresses
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl socket mail
by tachyon (Chancellor) on Dec 20, 2003 at 10:50 UTC | |
|
Re: perl socket mail
by atcroft (Abbot) on Dec 20, 2003 at 10:40 UTC | |
|
Re: perl socket mail
by jeffa (Bishop) on Dec 21, 2003 at 05:22 UTC | |
|
Re: perl socket mail
by pg (Canon) on Dec 20, 2003 at 17:18 UTC |