The following code results in a nagging little message on the web host which reads as follows:sendmail_with_attachments.cgi: Use of uninitialized value in concatenation (.) or string at sendmail_with_attachments.cgi line 49. I've figured out, that this is a scoping problem. Variables only are scoped (visible) to the block they are in when use strict is in place (as it should be). Please can you tell me how to prevent / correct the scoping error?
#! /usr/bin/perl -wT # use strict; #force all variables to be declared before use use CGI qw(:standard escapeHTML); # import most common gateway inte +rface functions use CGI::Carp qw(warningsToBrowser fatalsToBrowser); #cause all diagno +stics to be sent to browser use Mail::Sendmail; use MIME::Entity; print header; print start_html (-title => "email"); my $from = qq~"Me" <me\@here.com>~; my $to = qq~"You" <you\@there.com>~; my $cc = qq~"Him" <him\@overthere.com>~; my $bcc = qq~bccguy\@where.com>~; $ENV{PATH} = "/usr/sbin"; open (MAIL, "|/usr/sbin/sendmail -t") or &dienice("Can't fork for send +mail: $!\n"); print "Testing Mail::Sendmail version $Mail::Sendmail::VERSION&nbsp&nb +sp&nbsp&nbsp\n\n"; print "\n\nDefault server: $Mail::Sendmail::mailcf +g{smtp}->[0]&nbsp&nbsp&nbsp&nbsp\n\n"; my $top = MIME::Entity->build(Type => "multipart/mixed", From => "$from", To => "$to", Cc => "$cc", Bcc => "$bcc", Subject => "two attachment email"); $top->attach (Type =>"text/html", Encoding => "quoted-printable", Data => [ "<p><font size='3' face='Times' color='black'>HTML test:</font>\n\n", "<p><a href='http://www.anyoldsomethingforurl.com'> any old URL</a>\n\ +n", "<p><img src='http://www...../images/image1.jpg' height='361' width='2 +50' alt='any old image'>\n\n" ]); $top->attach (Path =>"/home/..../public_html/images/p +ower.pps", Type => "application/vnd.ms-powerpoint" +, Encoding => "base64", ); $top->attach (Path =>"/home/..../public_html/images/i +mage2.jpg", Type => "image/jpg", Encoding => "base64", ); $top->print(\*MAIL); print "\n\n\$Mail::Sendmail::log says:&nbsp&nbsp $Mail::Sendmail::log\ +n"; close(MAIL); print end_html; exit (0);

In reply to scoping problem with Mail::Sendmail by gmacfadden

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.