Well what im trying to do is create a form and once the person hits submit on the form it goes to a CGI-Perl Script and sends out a email to the shipping department so that they know to send out a demo. Anyways I have run into a problem, number one being lack of PERL knowledge. So i thought at first I had found the answer to my problems and I figured i would play with some PERL and tweak some examples to my specs. Here is the example i have found that I havent been able to get to work:
use strict;
use Net::SMTP;
my $globalMailServer = "127.0.0.1";
{
sendmail ('JoeCool@somewhere.com', # put
real e-mail address
+ here
'JoeCoolio', # put your real name here
+
'shipping@somewhere.com', # put dest e-mail address
+ here
'Shipping Department', # put dest name here
'You the man', # subject
'This probably wont work, but oh well.'); # message
}
sub sendmail
{
@_ == 6 or die "Improper number of arguments";
my ($fromemail, $fromname, $toemail, $toname, $subject, $message)
+= @_;
my $smtp = 0;
$smtp = Net::SMTP->new($globalMailServer) or die "Can't connect to
+ mail server named '$globalMailServer'\n";
$smtp->mail ($fromemail);
$smtp->to ($toemail);
$smtp->data ();
$smtp->datasend ("To: $toname\n");
$smtp->datasend ("From: $fromname\n");
$smtp->datasend ("Subject: $subject\n");
$smtp->datasend ("\n");
$smtp->datasend ($message);
$smtp->dataend ();
$smtp->quit;
}
NOTE: Originaly there was a path to the /Usr/bin/perl i belive it was, well i took that out because im under the impression it is not needed on a NT system running IIS 5. Also i tweaked this a little bit for this post. In the running example there are valid email adddresses and also valid SMTP server. The SMTP server im using is the one that comes with IIS 5, and currently im using that on several other projects that are running ASP's and Cold Fusion on the same server without any problems. I would imagine that in the errors im getting that the SMTP server is not the problem though.
THE ERROR:
(Get this if i run the program or run PERL -W filename)C:\>perl -w mailtest.pl
String found where operator expected at mailtestorg.pl line 9, near "here
'JoeCoolio'"
(Do you need to predeclare here?)
String found where operator expected at mailtestorg.pl line 13, near "here
'Shipping Department'"
(Do you need to predeclare here?)
syntax error at mailtestorg.pl line 9, near "here
'JoeCoolio'"
Execution of mailtest.pl aborted due to compilation errors.
END OF ERROR OUTPUT-
Okay so that is all of it in a nutshell. The original article i read stated that i should do a perl -e "user Net::SMTP" which i did and had received no errors.
Any ideas? What am i doing wrong with this?
Also please remember i am very new to PERL, so be kind :)
Thanks in advance.
twarfield@astcorp.com
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.