CoffeeDuke has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use CGI; use strict; use Date::Calc qw(Today Day_of_Week Add_Delta_Days); # Variables my ($start,$nextday,$mon,$counter,$day1,$mail); my ($year, $month, $day) = Today(); my $sendmail = "/usr/sbin/sendmail -oi -t -odq"; # E-Mail Config my $to_mail = "coffeeDuke\@gmail.com"; my $send_to = "To: $to_mail\n"; my $reply_to = "Reply-to: $to_mail\n"; my $subject = "Subject: Test Email Send From PerlScript\n"; # Main # NextDay = Mon-Fri | if Fri then NextDay = Mon if (Day_of_Week($year, $month, $day) || "1,2,3,4") { $counter = 1; $day1 = Today(); $day1 = Today() + $counter; $counter++; $nextday = $day1.$month.$year; $nextday = (length($day1) < 2) ? "0".$day1."." :$day1; $nextday .= (length($month) < 2) ? "0".$month : $month; $nextday .= "."; $nextday .= $year; } # Calc. Nextday if (Day_of_Week($year, $month, $day) == 5) { $counter = 3; $day1 = Today(); $day1 = Today() + $counter; $counter++; $nextday = $day1.$month.$year; $nextday = (length($day1) < 2) ? "0".$day1."." :$day1; $nextday .= (length($month) < 2) ? "0".$month : $month; $nextday .= "."; $nextday .= $year; } # Calc. Monday while (Day_of_Week($year, $month, $day) != 1) { ($year, $month, $day) = Add_Delta_Days($year, $month, $day, 1); } $mon = (length($day) < 2) ? "0".$day."." :$day; $mon .= (length($month) < 2) ? "0".$month : $month; $mon .= "."; $mon .= $year; # Send Email open(SM, "|$sendmail") or die "Cannot open $sendmail: $!"; print SM $reply_to; print SM $subject; print SM $send_to; print (SM "Content-type: text/html\n\n"); # Mail Body print (SM "<HTML><BODY>"); print (SM "Mail message from CoffeeDuke <BR><BR>"); print (SM "Write some usefull Text here..<BR><BR>"); print (SM "Next expected Backups of Coffee Server (local Time): <BR><B +R>"); print (SM "Master Server:" .$nextday, "around 10:00am <BR><BR> +"); print (SM "Backup Server:" .$mon, "around 10:30am <BR><BR>"); print (SM "Regards, <BR><BR>"); print (SM "Backup Service DukeCoffee<BR><BR>"); print (SM "</HTML></BODY>"); close(SM); __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Sendmail - how can I active use defined variables in the Message Body
by davido (Cardinal) on Aug 13, 2012 at 09:25 UTC | |
by CoffeeDuke (Initiate) on Aug 13, 2012 at 09:47 UTC | |
by davido (Cardinal) on Aug 13, 2012 at 10:01 UTC | |
by ww (Archbishop) on Aug 13, 2012 at 11:55 UTC | |
|
Re: Using Sendmail - how can I active use defined variables in the Message Body
by Marshall (Canon) on Aug 13, 2012 at 11:13 UTC | |
|
Re: Using Sendmail - how can I active use defined variables in the Message Body
by afoken (Chancellor) on Aug 13, 2012 at 18:11 UTC |