rahu_6697 has asked for the wisdom of the Perl Monks concerning the following question:
I'm new to PERL. I want to create a PERL Script that could send mail by taking all required fields from an input file present at desktop and can send a mail to everyone in mailing list (separated by comma) accordingly. Contents of my input data file is as follows:
Recipients are enclosed between tags TO & ENDTO.
Subject of mail is enclosed between SUBJECT & ENDSUBJECT.
Body of mail is enclosed between BODY & ENDBODY.
Sample data file :
TO
rahul@example.com,you@everyone.com
ENDTO
SUBJECT
Weekly status snapshot for WW-5
ENDSUBJECT
$mailprog = "/usr/sbin/sendmail"; my $file1 = 'message'; open my $ifh1, '<', $file1; local $/ = undef; my $contents = <$ifh1>; my $file2 = 'recipients'; open my $ifh2, '<', $file2; local $/ = undef; my $recip = <$ifh2>; close( $ifh2 ); close( $ifh1 ); $subject= "Weekly status snapshot for WW-3"; open(MAIL, "|$mailprog -t"); print MAIL "To: $recip \n"; #print MAIL "bcc: rahul.agarwal\@everyone.com\n"; print MAIL "From: rahul.agarwal\@everyone.com\n"; print MAIL "Subject: $subject\n\n"; print MAIL "$contents"; close(MAIL);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parse text file data to send a mail.
by hippo (Archbishop) on Feb 04, 2019 at 10:08 UTC | |
by rahu_6697 (Novice) on Feb 04, 2019 at 10:50 UTC | |
by hippo (Archbishop) on Feb 04, 2019 at 11:09 UTC | |
by poj (Abbot) on Feb 04, 2019 at 11:21 UTC | |
|
Re: Parse text file data to send a mail.
by choroba (Cardinal) on Feb 04, 2019 at 11:57 UTC | |
|
Re: Parse text file data to send a mail.
by Veltro (Hermit) on Feb 04, 2019 at 11:24 UTC | |
|
Re: Parse text file data to send a mail.
by karlgoethebier (Abbot) on Feb 04, 2019 at 21:40 UTC |