Mail Handling

First of all, a happy 2000 to you all.

second, in my continuing quest ;) of mailing attachements with sendmail and perl...

I use the following script:

#!/usr/bin/perl

use MIME::Lite;
         
     $top = build MIME::Lite   Type    => "multipart/mixed",
                               From    => "test@hab.nl",
                               To      => "j.brugman@hab.nl",
                               Subject => "Hello, nurse!";
     
     attach $top  Path=>"test.html";
     
     $sendmail  = '/usr/sbin/sendmail';
     open(MAIL, "|$sendmail -t");
     $top->print(\*MAIL);
     close MAIL;

(chmod 755)
When trying to test i get the following error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

Premature end of script headers: test.cgi


What could be wrong now and how do i solve it.

LVL 4
jbrugmanAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
monasConnect With a Mentor Commented:
did you try to run this without web server. Try to log into web server and run it ./script.cgi

I bet perl will say you that you need \ before every @ in email addresses...
0
 
monasCommented:
If you run this script as a cgi-script - then it MUST produce some web-page! Even empty one. So try to add

print "Content-Type: text/plain\n\n";

before use MIME::Lite;
0
 
jbrugmanAuthor Commented:
Done, Script is now:

#!/usr/bin/perl
print "Content-Type: text/plain\n\n";

use MIME::Lite;

$top = build MIME::Lite   Type    => "multipart/mixed",
                          From    => "test@hab.nl",
                          To      => "j.brugman@hab.nl",
                          Subject => "Hello, nurse!";
 
attach $top  Path=>"test.html";

$sendmail  = '/usr/sbin/sendmail';
open(MAIL, "|$sendmail -t");
$top->print(\*MAIL);
close MAIL;

but the server-error is still the same.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
struppiCommented:
is mime::Lite a standard libary ? in my version there are no.
may you must transfer the lite.pm file (in the perl/lib/mime/lite path, i guess) in your working directory and try to use it as "use Lite.pm".
0
 
KennyIT Application ExecutiveCommented:
Perhaps you can try changing your double quotes (") to single quotes (') because of the special characters in the email address (@,.).
0
 
jbrugmanAuthor Commented:
Together with your first command, and the last, i made it work!!!
I'm verry happy now :-))
0
 
jbrugmanAuthor Commented:
Done, Script is now:

#!/usr/bin/perl
print "Content-Type: text/plain\n\n";

use MIME::Lite;

$top = build MIME::Lite   Type    => "multipart/mixed",
                          From    => "test\@hab.nl",
                          To      => "j.brugman\@hab.nl",
                          Subject => "Hello, nurse!";
   
attach $top  Path=>"test.html";

$sendmail  = '/usr/sbin/sendmail';
open(MAIL, "|$sendmail -t");
$top->print(\*MAIL);
close MAIL;

0
All Courses

From novice to tech pro — start learning today.