Title: RE: Automatically Submit HTML/ASP Forms (fwd)

It was difficult to follow this message. I think Sankar responded to an earlier question, then asked how to generate an email message without sendmail.

I use NT, which also doesn't have sendmail, so I cobbled this together so I could send messages through Exchange.

use IO::Socket qw (:DEFAULT :crlf);

$info{"email_from_address"}="you\@yourdomain.com";
$info{"email_to_address"}="them\@theirdomain.com";
$info{"email_subject"}="subject";
$info{"email_message"}.="Thank you!<p>\n\n";
&send_email(*info);

# - send only
sub s {
        local($sock)=shift();
        local($msg)=shift();
        print $sock $msg;
        $msg =~ s/\r\n//g;
#       print "<code>Sent&gt;<b>$msg</b></code><br>\n";
}

# - send message. same as &s, but it doesn't show the message content.
sub s_message {
        local($sock)=shift();
        local($msg)=shift();
        print $sock $msg;
        $msg =~ s/\r\n//g;
#       print "<code>Sent&gt;<b>[message content]</b></code><br>\n";
}

# - send and recieve reply
sub sr {
        local($sock)=shift();
        local($msg)=shift();
        local($back);
        &s($sock,$msg);
        &r($sock);
}

# - recieve only
sub r {
        local($sock)=shift();
        local($back);
        recv ($sock, $back, 127,0);
        $back =~ s/</&lt;/g;
        $back =~ s/>/&gt;/g;
        $back =~ s/\r\n//g;
#       print "<code>Resp&gt;$back</code><br>\n";
}

sub send_email {
        local(*info)=shift;
        local(@errors);
       
        $info{"email_server"}="YOUR_EMAIL_SERVER" unless $info{"email_server"};
        push(@errors, "Email originator not specified") if (!$info{"email_from_address"} || $info{"email_from_address"}=~/^\@/);

        push(@errors, "Email recipient not specified") if (!$info{"email_to_address"} || $info{"email_to_address"}=~/^\@/);

        push(@errors, "No content to send") if (!$info{"email_message"});
       
        if (@errors) {
                print "<p>The document you wish to email is missing the following elements:<br>\n<code>";
                foreach $error (@errors) {
                        print "&nbsp;&nbsp;&nbsp;$error<br>\n";
                }
                print "</code>\n";
                exit;
        }
        $info{"email_to_address"} =~ s/\s//g;
        $info{"email_to_address"}.="\@YOURDOMAIN.COM" if ($info{"email_to_address"}!~/\@/);
        $sock=new IO::Socket::INET (
                PeerAddr => $info{'email_server'},
                PeerPort => '25',
                Proto => 'tcp',
        );
       
        if (!$sock) {
                print "Unable to connect to email server <b>$info{'email_server'}</b>: $!<br>\n";
                exit;
        }
       
        &r($sock);
       
        # - email message
        &sr($sock, "HELO yourdomain.com$CRLF");
        if ($info{'email_from_address'}) { &sr($sock,"MAIL FROM:$info{'email_from_address'} $CRLF"); }
        if ($info{'email_to_address'}) { &sr($sock, "RCPT TO:$info{'email_to_address'} $CRLF"); }
        &sr($sock, "DATA$CRLF");
        &s($sock, "Content-type:text/html$CRLF");
        if ($info{'email_subject'}) { &s($sock, "Subject:$info{'email_subject'}$CRLF"); }
        if ($info{'email_from_name'}) { &s($sock, "From:$info{'email_from_name'}$CRLF"); }
        if ($info{'email_to_name'}) { &s($sock, "To:$info{'email_to_name'}$CRLF"); }
        if ($info{'email_cc_address'}) { &s($sock, "CC:$info{'email_cc_address'}$CRLF"); }
        if ($info{'email_bcc_address'}) { &s($sock, "BCC:$info{'email_bcc_address'}$CRLF"); }
        &s($sock, "$CRLF");
        if ($info{"email_message"}) { &s_message($sock, $info{"email_message"}); }
        &sr($sock, "$CRLF.$CRLF");
        &sr($sock, "QUIT$CRLF");
}

-----Original Message-----
From: P.V.Sankar [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 14, 2001 3:51 AM
To: [EMAIL PROTECTED]
Subject: Automatically Submit HTML/ASP Forms (fwd)



 Without user intervention it is not possible to login to a website.

my requirement is , first user gets the form from the
web-server[windowsNT], after
filling the details [HTML form] , when the user submits the form, all
those details should reach my mail account, which is in a Sun-solaris
machine.without using mail & sendmail modules, i want to know how it can
be implemented,because my system doesn't have those modules.
i don't know whether it can be done over SSL connection
expecting an early response

regards,
sankar
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to