[Xitami] (no subject)
Brian {Hamilton Kelly}
xitami@lists.xitami.org
Mon, 15 Jul 2002 18:52:41 +0100
In message <OE64XqtFpsTfQqfJD9w0000b271@hotmail.com>
"Neco Computers" writes:
> > What is that best way to send E-mail through CGI Perl scripts, using
> Xitami? Also if you
> > can supply some Perl Syntax for doing so. I am use to UNIX, and I'm not
> sure how to do
> > this on a Windows server.
>
> You can use sockets to send email:
>
> use Net::SMTP;
> my $smtp = Net::SMTP->new($smtp_server, Debug => 0) || die "unable to
> create Net::SMTP object $smtp_server.";
> $smtp->mail($Webmaster);
Hmm; interesting. Presumably the mail() function issues an SMTP "MAIL
FROM: <$Webmaster>" and awaits a positive response? What happens if it
gets a temporary (or permanent) error response?
> $smtp->to($Email);
and then a "RCPT TO: <$Email>". Again, there are various legitimate
responses to this, and only a few of them indicate success.
> $smtp->data();
followed by a "DATA" command. What happens to the script if any of these
operations encounter a non-success response from the remote SMTP server?
> $smtp->datasend("From: $Webmaster\n");
> $smtp->datasend("Subject: $subject\n");
> $smtp->datasend("\n");
OK, that's two header lines, and the blank line that separates the header
from the body. Does Net::SMTP automatically insert such (nowadays
mandatory under RFC-2822) headers as "Date:"?
> $smtp->datasend($message);
Presumably the datasend() function is capable of sending the embedded
newslines?
> $smtp->dataend();
which presumably sends the "." on a line of its own, to terminate the
DATA transfer.
What happens if the remote end fails to accept the message at this point?
RFC-2821 makes it quite clear that unless the SMTP client has received a
"success" code following the end of that part of the exchange, it must
NOT assume that the mail has been successfully sent, and undertake to
requeue it in some fashion.
> $smtp->quit();
It strikes me that all these functions should return error conditions,
and the script be written to handle such errors gracefully. Did the
author assume that a mail transfer will always execute without error?
--
Brian {Hamilton Kelly} bhk@dsl.co.uk
"We have gone from a world of concentrated knowledge and wisdom to one of
distributed ignorance. And we know and understand less while being incr-
easingly capable." Prof. Peter Cochrane, formerly of BT Labs