Hi fellow monks,

A friend of mine recently asked if I could write a perl program that would send an email from a file. It seems he would like to periodically email a list of his students from a file he has written ( lecture notes, homework assignments, etc. ). So, this is the 'project' so far:

#!\usr\bin\perl -wT use strict; use Net::SMTP; use CGI qw ( :standard ); my ( $from, $to, $subject, $message, $address, $server, $myAddress ); $from = param( "from" ); $to = param( "to" ); $subject = param( "subject" ); $message = param( "message" ); $address = param( "address" ); $server = param( "server" ); $myAddress = param( "myAddress" ); my $smtp = new Net::SMTP( "$server", Hello => "$server" ) or die "Ughh! Unable to send email : $!\n"; $smtp->to( "$to ); $smtp->mail( "$myAddress" ); $smtp->data(); $smtp->datasend( "From: $from\n" ); $smtp->datasend( "To: $to\n" ); $smtp->datasend( "Subject: $subject\n\n\n" ); $smtp->datasend( "$message\n" ); $smtp->dataend(); $smtp->quit();


If the $message that he wanted to send was stored in a file called "syllabus.txt", how would I include that file name in place of the message text?

Thanks in advance,

-Katie.

In reply to Sending email from a file. by DigitalKitty

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.