Discussion:
Send attechment whiet smtp perl script
(too old to reply)
davesimons
2006-11-13 09:47:13 UTC
Permalink
Hello,

I'm using the sendmail.pl file on my Netware 6.5 server to send some
standart mail to the admin user.

I realy would like to send a log file every now 2 day's to the admin user
mailbox. White the sendmail.pl file in the sys:perlscript i only can send
an text mail whitout an attechment.

I don't know anything of perl programming, dan someone help me

Thanx a lot

Dave Simons
CNE6
Guenter
2006-11-13 16:41:20 UTC
Permalink
Hi Dave,
take a look at this old script from me:
http://www.gknw.net/nwperl/perlscripts/mailtail.txt
it uses Mail::Sender which can handle attachments.

Guenter.
Post by davesimons
Hello,
I'm using the sendmail.pl file on my Netware 6.5 server to send some
standart mail to the admin user.
I realy would like to send a log file every now 2 day's to the admin user
mailbox. White the sendmail.pl file in the sys:perlscript i only can send
an text mail whitout an attechment.
I don't know anything of perl programming, dan someone help me
Thanx a lot
Dave Simons
CNE6
davesimons
2006-11-14 09:24:33 UTC
Permalink
Hello Guenter,

Whre do i need to enter the attchemnt file.

i don't who this script can send an attechment

Thanx for helping

Dave
Post by Guenter
Hi Dave,
http://www.gknw.net/nwperl/perlscripts/mailtail.txt
it uses Mail::Sender which can handle attachments.
Guenter.
Post by davesimons
Hello,
I'm using the sendmail.pl file on my Netware 6.5 server to send some
standart mail to the admin user.
I realy would like to send a log file every now 2 day's to the admin user
mailbox. White the sendmail.pl file in the sys:perlscript i only can send
an text mail whitout an attechment.
I don't know anything of perl programming, dan someone help me
Thanx a lot
Dave Simons
CNE6
Guenter
2006-11-14 09:50:55 UTC
Permalink
Hi Dave,
Post by davesimons
Hello Guenter,
Whre do i need to enter the attchemnt file.
i don't who this script can send an attechment
oups! Wrong sample....; will look for a better one soon...

G.
davesimons
2006-11-14 15:01:45 UTC
Permalink
oke, thanx.
Post by Guenter
Hi Dave,
Post by davesimons
Hello Guenter,
Whre do i need to enter the attchemnt file.
i don't who this script can send an attechment
oups! Wrong sample....; will look for a better one soon...
G.
Guenter
2006-11-14 19:07:15 UTC
Permalink
Hi Dave,
***@etthome.nl (davesimons) wrote in news:tTk6h.3308$***@prv-
forum2.provo.novell.com:

please try this one:
http://www.gknw.net/nwperl/perlscripts/tstmailatt.txt

greetz, Guenter.
davesimons
2006-11-15 10:00:58 UTC
Permalink
Hello Guenter,

what line's should i edit ??

I know the: from, file and host but what other lines should i edit to make
the script work

Thanx Dave
Post by Guenter
Hi Dave,
http://www.gknw.net/nwperl/perlscripts/tstmailatt.txt
greetz, Guenter.
Guenter
2006-11-15 11:15:21 UTC
Permalink
Hi Dave,
Post by davesimons
Hello Guenter,
what line's should i edit ??
I know the: from, file and host but what other lines should i edit to make
the script work
try the version below - I have removed the parameter, and made everything
setable from the script - see comments.

#!/perl/bin/perl -w

use Mail::Sender;

# Configure your SMTP server
my $smtp = '192.168.1.1';
# Configure your recipient
my $to = 'admin\@domain.tld';
# Configure your sender
my $from = '"Service Auto Mailer" <scriptengine\@MYSERVER>';
# Configure the file to attach
my $file = 'sys:/public/RootCert.der';
# Configure the subject of the mail
my $subj = 'Test Mail (1 Attachment)';
# Configure the message body of the mail
my $msg = "This is a testmail with attachment! No reply required!\nFile:
$file\n";

# ********** nothing to configure below **********

if (!-e $file) {
print "Error: $file not found!\n";
exit;
}
$sender = new Mail::Sender{smtp => $smtp, from => "\"Service Auto Mailer\"
<$from>"};
if ($sender->MailFile({to => $to, subject => $subj, msg => $msg, file =>
$file})) {
print "\r$0: Mail sent OK.\n";
} else {
print "\rError sending mail!\n";
}
exit;
davesimons
2006-11-15 14:24:16 UTC
Permalink
mmmm i get the following error in my logegr screen of the Netware 6.5
server:

Can't locate Mail/Sender.pm in @INC (@INC contains: sys:perllib perlscripts
at sys:perlscriptstest.pl line 3.

BEGIN failed--compilation aborted at sys:perlscriptstest.pl line 3.

<Press any key to continue...>


What can be wrong ??

i really appreciate that you help me

Dave
Post by Guenter
Hi Dave,
Post by davesimons
Hello Guenter,
what line's should i edit ??
I know the: from, file and host but what other lines should i edit to
make
Post by davesimons
the script work
try the version below - I have removed the parameter, and made everything
setable from the script - see comments.
#!/perl/bin/perl -w
use Mail::Sender;
# Configure your SMTP server
my $smtp = '192.168.1.1';
# Configure your recipient
# Configure your sender
# Configure the file to attach
my $file = 'sys:/public/RootCert.der';
# Configure the subject of the mail
my $subj = 'Test Mail (1 Attachment)';
# Configure the message body of the mail
$filen";
# ********** nothing to configure below **********
if (!-e $file) {
print "Error: $file not found!n";
exit;
}
$sender = new Mail::Sender{smtp => $smtp, from => ""Service Auto Mailer"
<$from>"};
if ($sender->MailFile({to => $to, subject => $subj, msg => $msg, file =>
$file})) {
print "r$0: Mail sent OK.n";
} else {
print "rError sending mail!n";
}
exit;
cperry
2006-11-15 16:17:20 UTC
Permalink
Sounds like a pathing issue. Is Sender.pm on your system?
Post by davesimons
mmmm i get the following error in my logegr screen of the Netware 6.5
at sys:perlscriptstest.pl line 3.
BEGIN failed--compilation aborted at sys:perlscriptstest.pl line 3.
<Press any key to continue...>
What can be wrong ??
i really appreciate that you help me
Dave
Post by Guenter
Hi Dave,
Post by davesimons
Hello Guenter,
what line's should i edit ??
I know the: from, file and host but what other lines should i edit to
make
Post by davesimons
the script work
try the version below - I have removed the parameter, and made everything
setable from the script - see comments.
#!/perl/bin/perl -w
use Mail::Sender;
# Configure your SMTP server
my $smtp = '192.168.1.1';
# Configure your recipient
# Configure your sender
# Configure the file to attach
my $file = 'sys:/public/RootCert.der';
# Configure the subject of the mail
my $subj = 'Test Mail (1 Attachment)';
# Configure the message body of the mail
$filen";
# ********** nothing to configure below **********
if (!-e $file) {
print "Error: $file not found!n";
exit;
}
$sender = new Mail::Sender{smtp => $smtp, from => ""Service Auto Mailer"
<$from>"};
if ($sender->MailFile({to => $to, subject => $subj, msg => $msg, file =>
$file})) {
print "r$0: Mail sent OK.n";
} else {
print "rError sending mail!n";
}
exit;
Guenter
2006-11-16 02:36:39 UTC
Permalink
Dave,
Post by davesimons
mmmm i get the following error in my logegr screen of the Netware 6.5
at sys:perlscriptstest.pl line 3.
BEGIN failed--compilation aborted at sys:perlscriptstest.pl line 3.
<Press any key to continue...>
What can be wrong ??
i really appreciate that you help me
please re-read my first post where I pointed to perl_mail.zip on my site;
download it and extract to your sys volume with full path names.

Guenter.
davesimons
2006-11-16 08:12:30 UTC
Permalink
oke thnax,

i only now get this error:

Error sending mail!
<Press any key to continue...>

Dave
Post by Guenter
Dave,
Post by davesimons
mmmm i get the following error in my logegr screen of the Netware 6.5
at sys:perlscriptstest.pl line 3.
BEGIN failed--compilation aborted at sys:perlscriptstest.pl line 3.
<Press any key to continue...>
What can be wrong ??
i really appreciate that you help me
please re-read my first post where I pointed to perl_mail.zip on my site;
download it and extract to your sys volume with full path names.
Guenter.
Guenter
2006-11-16 13:19:51 UTC
Permalink
Hi Dave,
Post by davesimons
oke thnax,
Error sending mail!
<Press any key to continue...>
that means that you have configured something wrong. Probably you forgot to
escape the @ in the mail address ( \@ ) ...
Please re-check all settings again; f.e. most mailservers reject the mail if
the sender is non-local or otherwise wrong...

I have self tested the script, and it works fine....

greetz, Guenter.
davesimons
2006-11-16 17:33:35 UTC
Permalink
mmm this is my file:

#!/perl/bin/perl -w

use Mail::Sender;

# Configure your SMTP server
my $smtp = 'fs02';
# Configure your recipient
my $to = '***@pantein.nl';
# Configure your sender
my $from = '"Service Auto Mailer" <***@pantein.nl>';
# Configure the file to attach
my $file = 'sys:/system/pwdntfy.log';
# Configure the subject of the mail
my $subj = 'Test Mail (1 Attachment)';
# Configure the message body of the mail
my $msg = "This is a testmail with attachment! No reply required!nFile:
$filen";

# ********** nothing to configure below **********

if (!-e $file) {
print "Error: $file not found!n";
exit;
}
$sender = new Mail::Sender{smtp => $smtp, from => ""Service Auto Mailer"
<$from>"};
if ($sender->MailFile({to => $to, subject => $subj, msg => $msg, file =>
$file})) {
print "r$0: Mail sent OK.n";
} else {
print "rError sending mail!n";
}
exit;

----------------------------

dns is running fine on the server so servername fs02 is resolved
correctly, if i enter an ipadress it gives the same result


hope you see sonething wrong

thanx again

Dave
Post by Guenter
Hi Dave,
Post by davesimons
oke thnax,
Error sending mail!
<Press any key to continue...>
that means that you have configured something wrong. Probably you forgot to
Please re-check all settings again; f.e. most mailservers reject the mail if
the sender is non-local or otherwise wrong...
I have self tested the script, and it works fine....
greetz, Guenter.
Guenter
2006-11-16 19:32:34 UTC
Permalink
Hi Dave,
Post by Guenter
#!/perl/bin/perl -w
use Mail::Sender;
# Configure your SMTP server
my $smtp = 'fs02';
# Configure your recipient
# Configure your sender
# Configure the file to attach
my $file = 'sys:/system/pwdntfy.log';
# Configure the subject of the mail
my $subj = 'Test Mail (1 Attachment)';
# Configure the message body of the mail
$filen";
# ********** nothing to configure below **********
if (!-e $file) {
print "Error: $file not found!n";
exit;
}
$sender = new Mail::Sender{smtp => $smtp, from => ""Service Auto Mailer"
<$from>"};
if ($sender->MailFile({to => $to, subject => $subj, msg => $msg, file =>
$file})) {
print "r$0: Mail sent OK.n";
} else {
print "rError sending mail!n";
}
exit;
----------------------------
dns is running fine on the server so servername fs02 is resolved
correctly, if i enter an ipadress it gives the same result
hope you see sonething wrong
sorry, but no - the script gets busted since I see no backslashes at all
through the script (at least with my newsreader - and when I look at my own
post I can see backslashes in the post)
but you said initially that you sent successfully with the sendmail.pl -
have you tried with exact same from & to settings?
Make sure that $from is set correctly and that the @ is escaped with a
backslash; also you can simplify the $from:
my $from = 'scriptengine\@MYSERVER';
is enough - the rest was cosmetic....
also you should enable debug mode on the mail server if possible, and then
check the logs - perhaps you can see there that the mail arrives, but the
mailserver refuses to accept it, and hopefully the reason why.....

good luck!
Guenter.
davesimons
2006-11-17 08:23:47 UTC
Permalink
Hello Guenter,

i have been some tests en when i remark this line a mail is send to mee
but the attechment is not in the mail

----------------
my $msg = "This is a testmail with attachment! No reply required!nFile:
$filen";
----------------

i think it has something to to white my editing. Should i also edit
something is this line ?? maybe i chould change the word "file" ??

sorry, i but i really haven't any expiriance whit perl :-))

Thanx Dave
Post by Guenter
sorry, but no - the script gets busted since I see no backslashes at all
through the script (at least with my newsreader - and when I look at my own
post I can see backslashes in the post)
but you said initially that you sent successfully with the sendmail.pl -
have you tried with exact same from & to settings?
is enough - the rest was cosmetic....
also you should enable debug mode on the mail server if possible, and then
check the logs - perhaps you can see there that the mail arrives, but the
mailserver refuses to accept it, and hopefully the reason why.....
good luck!
Guenter.
Guenter
2006-11-17 09:23:53 UTC
Permalink
Hi Dave,
Post by davesimons
Hello Guenter,
i have been some tests en when i remark this line a mail is send to mee
but the attechment is not in the mail
----------------
$filen";
----------------
i think it has something to to white my editing. Should i also edit
something is this line ?? maybe i chould change the word "file" ??
sorry, i but i really haven't any expiriance whit perl :-))
hmm, strange. I guess same - something must be wrong with editing....
I have just put the script on my site:
http://www.gknw.net/nwperl/perlscripts/tstmailatt2.txt
try to save this directly, and dont use copy&paste.
perhaps more easy is if you look here at the index:
http://www.gknw.net/nwperl/perlscripts/
there right-click the script tstmailatt2.txt and select 'save'...
then rename to tstmailatt2.pl
If you want to edit from workstation then use a real editor, f.e. I recommend
to use MED:
http://www.utopia-planitia.de/indexus.html
or edit directly from server console with edit.nlm...

greets, Guen.
davesimons
2006-11-17 10:26:11 UTC
Permalink
Guenter,

Yessssssssssssss, it is working right now. I think the hole problem was
that when i copy and pasted in my pl file the scipt was being mestup.

know i downloaded it from your site just as you told me, i edit it white
Crimson editor........ and working !!!!

Thanx you verry must for helping me on this one. If i ever need any help
white Perl i know to find you :-))

Now i will have look at your site, i sa you have a lot of nice perl
scripts, maybe i can use some o them, if thats oke white you ??

Thanx Dave Simons
Post by Guenter
hmm, strange. I guess same - something must be wrong with editing....
Guenter
2006-11-17 12:57:06 UTC
Permalink
Hi Dave,
Post by davesimons
Guenter,
Yessssssssssssss, it is working right now. I think the hole problem was
that when i copy and pasted in my pl file the scipt was being mestup.
know i downloaded it from your site just as you told me, i edit it white
Crimson editor........ and working !!!!
great!
Post by davesimons
Thanx you verry must for helping me on this one. If i ever need any help
white Perl i know to find you :-))
FYI I have also my own forums:
http://www.gknw.de/phpbb/
Post by davesimons
Now i will have look at your site, i sa you have a lot of nice perl
scripts, maybe i can use some o them, if thats oke white you ??
sure - that's public and the reason why it is there!
here are some more:
http://www.gknw.net/nwperl/perlucx/
but take care: many of these scripts are older, and could be done better now;
most are from NW5 times, and need probably some tweaking...

greetz, Guenter.

Loading...