Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sent HTML attachment with out using MIME:LITE

Status
Not open for further replies.

dshaw21369

Programmer
Jul 8, 2002
64
I have had lots of problems with installation of MIME:LITE (the make program is not available on our server), and Im frusturating our Unix admin.
I want to know if there is an easier way to sent an email with an HTML attachment.

Thanks.
 
Here is a very brief example of using uuencode to 'wrap' your
attachment. The attachment is then just tacked onto the end
of the outgoing mail.
Code:
$mail_prog = '/usr/lib/sendmail';
`unix2dos $input_file | uuencode attachemnt.txt >$output_file`; 

open(IPF,&quot;<$output_file&quot;) or showError(&quot;Failed to open IPF, $!&quot;);
while (<IPF>) { $mail_buffer .= $_; }
close IPF;

open (MAIL, &quot;|$mail_prog -f SENDER $recipient&quot;) 
    or die &quot;Can't open $mail_prog!, $!&quot;;
print MAIL &quot;From: $recipient\n&quot;;
print MAIL &quot;Reply-To: $recipient\n&quot;;
print MAIL &quot;Errors-to: $recipient\n&quot;;
print MAIL &quot;Subject: New Mail \n&quot;;
print MAIL &quot;Precedence: bulk\n\n&quot;;
print MAIL &quot;---------------------------------\n&quot;;
print MAIL &quot;Your attachment.\n&quot;;
print MAIL &quot;$mail_buffer\n&quot;;
close (MAIL);

I've hacked a bunch of stuff out of this to sanitize it a little,
but hopefully it illustrates one possible approach. 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Finally, I see an atachment!!! Thanks for your help!!! Now how can the user view it as html?

#!/usr/bin/perl

$yesterday = time() - 86400; # 86400 is num seconds in 1 day
($sec, $min, $hours, $day_of_month, $month, $year , $wday, $yday, $isdst) = localtime($yesterday);
$month++;
$yesterdays_date= sprintf(&quot;%02d/%02d/%02d&quot;, $month, $day_of_month, $year % 100);

$yesterdays_file= sprintf(&quot;reports_%02d/%02d/%02d.htm&quot;, $month, $day_of_month, $year % 100);
$mail_prog = '/usr/lib/sendmail';
$output_file='/export/home/egate/egate/client/SeeBeyond_Daily_Output_Files/temp';
$recipient='denesa.k.shaw@centerpointenergy.com';
$input_file= '/export/home/egate/egate/client/SeeBeyond_Daily_Output_Files/$yesterdays_file';

`unix2dos $input_file | uuencode attachemnt.txt >$output_file`;

open(IPF,&quot;<$output_file&quot;) or showError(&quot;Failed to open IPF, $!&quot;);
while (<IPF>) { $mail_buffer .= $_; }
close IPF;

open (MAIL, &quot;|$mail_prog -f SENDER $recipient&quot;)
or die &quot;Can't open $mail_prog!, $!&quot;;
print MAIL &quot;From: $recipient\n&quot;;
print MAIL &quot;Reply-To: $recipient\n&quot;;
print MAIL &quot;Errors-to: $recipient\n&quot;;
print MAIL &quot;Subject: New Mail \n&quot;;
print MAIL &quot;Precedence: bulk\n\n&quot;;
print MAIL &quot;---------------------------------\n&quot;;
print MAIL &quot;Your attachment.\n&quot;;
print MAIL &quot;$mail_buffer\n&quot;;
close (MAIL);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top