Hello Monks,

I've been assigned as the webmaster for my AFROTC detachment at New Mexico State U. I've been able to hold my own managing the existing HTML of the site however I have nil experience with scripting/coding and our perl script that handles our e-mail broadcast system recently has gone down.

I've been in communication with our the IT guys with the university and they've advised they've fixed issues with some modules that weren't installed and were blocking our script's functionality. I'm still getting errors when running the e-mail script though, unfortunately. (see here: http://web.nmsu.edu/~afrotc/cgi-bin/cadet_email.pl)

this is the error that I receive in case the vpn doesn't let you guys access it...
Sorry, cannot open /home/canto8/~afrotc/public_html/tmp2/: No such file or directory Cannot close /home/canto8/~afrotc/public_html/tmp2/: Bad file descriptor
I thought it might be a simple fix with regard to creating/setting permissions of a public_html/tmp2 directory. No dice. I've attached the perl script for our e-mail system here.. My request is more of a troubleshooting more than anything else, but if someone happens to append any improvements on what we have, we'd be most grateful.

Sincerely,

C/ Robin Deguzman
#!/usr/bin/perl -wT ################### #Create new object of type CGI #################### use CGI; use MIME::Lite; $query = new CGI; ##################### #grab text # ##################### print "Content-type: text/html\n\n"; $cc = $query->param("Ccemail"); $from = $query->param("From"); $subject = $query->param("Subject"); $comment = $query->param("Comment"); $file = $query->param("Attach"); @list = $query->param("list"); @name = split(/\\/, $file); #finds all /'s # $name = $name[$#name]; #finds last / and assumes name is afterward $name = $name[$#name]; #finds last / and assumes name is afterward # my $FILE = "/home/wsc13/pub_html/Academic_Progs/CAS/afrotc/public_ht +ml/tmp/"; my $FILE = "/home/canto8/~afrotc/public_html/tmp2/"; my $type = "application/octet-stream";chmod $list=join(",", @list); ################### #Mail form # ################### @extension = split(/\./, $name); $extension = $extension[$#extension]; # These file types should be okay:doc, docx, gif, jpg, pdf, ppt, txt, +xls # allowed file types to upload @goodfiles = ("doc","docx","gif","jpg","pdf","ppt","txt","xls","rtf"," +odt","zip"); &fileopen; sub fileopen { open(UPLOAD, "+>$FILE/$name") or print "Sorry, cannot open $FILE: + $!<br>"; my ($data, $chunk); while ($chunk = read($file, $data, 1024)) { print UPLOAD $data; } close(UPLOAD) or print "Cannot close $FILE: $!<br>"; #chmod(0777, "$FILE") or print "Cannot chmod $FILE: $!<br>"; # $msg = "You attached file $name"; my $mime_msg = MIME::Lite->new( From => $from, To => $list, Cc => $cc, Subject => $subject, Type => 'text/plain', Data => $comment ); # JMD: Need to have mimetype and encoding type my ($mime_type, $encoding) = ('application/octet-stream','base64') +; # Attach the file $mime_msg->attach( Type => $type, # JMD: Seems to only work this way, without Filename attritbut +e, don't know why. Path => "$FILE$name", Disposition => 'attachment' ) or dienice("Cannot upload attachment: $!"); #MIME::Lite->send('sendmail', "/usr/lib/sendmail -t -oi -oem"); $mime_msg->send(); print "$_<br>"; unlink($FILE); } sub Error { die "No File uploaded or incorrect filetype"; } ############################################# #Printing a message to the user ############################################# print "Content-type: text/html\r\n\r\n"; print "Emailing the following content: \n\n"; print "$comment \n\nAttachment:$name \n"; #print "$msg\n"; print "To: $list\n"; #print "This is the query file:\n $query\n"; ############################################# #Mailing construct ############################################

In reply to Web broadcast e-mail perl script by goosenoose

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.