Josh Brown wrote: > Mazhar wrote: > >> Hi Folks, >> i have a requirement where in i need to send alerts to a set >> of users for which i have developed a script and it is working fine. >> For the body of the mail i am writing into a text file everytime and i >> am sending across using the command, >> >> cat "textfilename" | mail -s "Subject" set of users >> >> This above is working fine i need help for sending the same >> textfile as a HTML file as the body of the mail please help me. >> >> Thanx in Advance >> >> Regards >> Mazhar >> >> >> > Hi Mazhar, > > What I do is open a filehandle to the sendmail application, then I print > in the headers I want. > You can be very flexible with it and there really is no guess work. >
There is lots of guess work. What if the path is different, are you going to code in every possible system location, or just hope the path is correct and open a security hole. What about necessary switches to sendmail? What if sendmail isn't even installed? What if no command line mail handler is installed? What if you want to send both text and html, then you need to setup boundaries and a proper preamble. Avoid the headaches, stick with a module that will handle all of that for you. Dealing with mail messages by hand is or will quickly become a nightmare. http://danconia.org > Here is a quick example. > open (MAIL, "|/usr/sbin/sendmail $recipient") or die "Could > not open sendmail"; > print MAIL "To: $recipient\n"; > print MAIL "From: $sender\n"; > print MAIL "Subject: $subject\n"; > print MAIL "Content-Type: text/html\n\n"; > print MAIL "$html\n"; > print MAIL "\n."; > close MAIL; > > That should work just fine, it is only for one recipient but I think you > just have to make sure they are seperated by spaces. > > Hope that helps, > -JB > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>