Here is my code. Like I said, this is my first stabb at something
usefull, actually my first time period. The print statement
that is printing all of the variables before they are passed to the subroutine
is there just so that I could see what was actually being passed on to the sub.
The "address.mail" file is a flat, array type file with one entry per line.
Here it is:
#!/usr/gnu/bin/perl -w
use Mail::Sender;
$mail = "address.mail"; # flat file passed from another program
if (-e $mail) {
open (FILE,$mail);
@mailf = <FILE>;
close FILE;
$addr = $mailf[0]; # assigning mail variables
$subj = $mailf[1]; # in the order that they
$from = $mailf[2]; # are in the file
$body = $mailf[3];
$attach = $mailf[4];
print "$addr\n $subj\n $from\n $body\n $attach\n";
sender_mail($addr,$subj,$body,$attach);
}
}
sub sender_mail {
ref ($sender = new Mail::Sender ({
from => '$addr', smtp => 'my.mailhub.com'})) # have to
+ be carfull with the hostname.
|| die "Mail::Sender::Error, $!";
(ref ($sender->MailFile(
{to =>"$addr", subject =>"$subj", msg =>"$body", file
+=> "$attach"})))
}
Edit: chipmunk 2001-06-05
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.