Hi Perl Monks, Sorry for a n00b question but I am quite new to Perl. I am actively learning and have a little starter project. I am writing a small script that would send an email with some details about an event happening on diff. dates. All works ok so far except the dates I calculated $nextday and $mon, those I wanted to add in the email Body and that does not work. I only get the "text" printed like this: "Next expected eMails from MCP (local Time): Server Start: $NEXTDAY, around 10:00" Here is my script: It returns exact what is written in the Body, but I want to see the 2 Variables return the actual Value (date). Thanks for your help.
#!/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__

In reply to Using Sendmail - how can I active use defined variables in the Message Body by CoffeeDuke

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.