Sponsored Content
Top Forums Shell Programming and Scripting Script to Convert HTML to MIME mail -- HELP! Post 302310734 by sushisan on Sunday 26th of April 2009 09:34:02 PM
Old 04-26-2009
Script to Convert HTML to MIME mail -- HELP!

Hi:

I have writed a script that read a HTML file and convert this in a multipart mime fail to send in a mail.

But the result isn't interpreted lika a mime file!!

Somebody can see the error???

---------------------------
Code:
#! /bin/bash
SB=$1
IF=$2
OF=$3
rm -f $OF.b64

BND="----------sushipart"

# CUERPO DEL MENSAJE
echo -ne "Subject: $SB\n\n">$OF.tmp
echo "MIME-Version: 1.0">>$OF.tmp
echo "Content-Type: multipart/related;">>$OF.tmp
echo " boundary=\"$BND\";">>$OF.tmp
echo -ne " type=\"multipart/alternative\"\n\n">>$OF.tmp
echo "This is a multi-part message in MIME format.">>$OF.tmp
echo "$BND">>$OF.tmp
echo "Content-Type: text/html; charset=ISO-8859-1">>$OF.tmp
echo -ne "Content-Transfer-Encoding: 7bit\n\n">>$OF.tmp
cat $IF>>$OF.tmp
echo -ne "\n$BND">>$OF.tmp

# MIME DE LOS ARCHIVOS
IMGS=$(cat $OF.tmp|tr -d '"'|awk '/<IMG SRC=/{A=substr($0,index($0,"SRC="));B=index(A," ");C=substr(A,1,B);D=substr(C,5);printf ("%s ",D)}')
for n in $IMGS;do
  ID="part1.$n@mimesushi.com"
  MITY=$(cat mime.types|awk -v MT="$(echo $n|awk '{for(i=length($0);i>=1;i--) if (substr($0,i,1)==".") {print substr ($0,i);break}}')" '{if (MT == $1) {printf("%s\n",$2);exit}}')
  echo -ne "Convirtiendo: $n -> $ID\n"
  echo -ne "\nContent-Type: $MITY;\n">>$OF.b64
  echo "  name=\"$n\"">>$OF.b64
  echo "Content-Transfer-Encoding: base64">>$OF.b64
  echo "Content-ID: <$ID>">>$OF.b64
  echo "Content-Disposition: inline;">>$OF.b64
  echo -ne "  filename=\"$n\"\n\n">>$OF.b64

  base64 $n>>$OF.b64
  echo -ne "$BND">>$OF.b64

  cat $OF.tmp|sed "s/$n/cid:$ID/g">$OF.tmp
done
echo "--">>$OF.b64
cat $OF.tmp $OF.b64>$OF


Last edited by otheus; 04-27-2009 at 06:54 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using MIME to send html files

:confused: I am a programmer, but need to work with UNIX in this particular situation. I am used to the plain "mail -s" command and also familiar with how to send attachments in html... but I now need to send an email (not an attachment) in html format so I can embed links... etc. I am told... (2 Replies)
Discussion started by: cgardiner
2 Replies

2. Shell Programming and Scripting

how to send mail in UNIX using MIME

Hi, I am searching for an option to send mail with multiple attachments using unix. I know uuencode option, but I dont have the executable in our machines. So I am looking for some other option to do this. And I heard that we can send mails using MIME. Can anyone help me with the syntax and... (2 Replies)
Discussion started by: srilaxmi
2 Replies

3. Shell Programming and Scripting

Awk script to convert csv to html

Hi Written some script to convert csv to html but could not add table headers.Below are the errors iam getting ./csv2html | more + awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\"... (2 Replies)
Discussion started by: zeebala1981
2 Replies

4. Shell Programming and Scripting

MIME - HTML mail with Excel attachment - Please help!

#!/bin/ksh ( echo "MIME-Version: 1.0" echo "Content-Type: multipart/mixed; boundary=frontier" echo "--frontier" echo "Content-Type: text/html" echo "Content-Disposition: inline" echo "\n" echo "<html><body><h1>this is html formatted text</h1></body></html>" echo "--frontier" echo... (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

5. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

6. Shell Programming and Scripting

Need to convert datafeed to html using script

Hi All, I am having datafeed content in CSV format like below. Any help to create a script. I need read the CSV file on loop and update it in html format for web publishing I want to chage the data using my token based template and save the file out to new csv file (3 Replies)
Discussion started by: ranjancom2000
3 Replies

7. Shell Programming and Scripting

Script to convert CSV file to HTML

Hi, I have made a a script which creates a csv file as daily database report However i want to covert that csv file to html because csv file does not have a good visibilty. So it is possible to have such csv to html coversion script. Your prompt help much appreciated. Thanks in advance (4 Replies)
Discussion started by: sv0081493
4 Replies

8. Shell Programming and Scripting

Script to convert csv file to html with good visibility

Hi, I have Below script which converts csv file to html succesfully.but the visiblity is simple in black n white. I want to have better visibilty of each columns in different colours(like green).As it is a Database report suppose some tablespace available space is less than 20% then it should... (7 Replies)
Discussion started by: sv0081493
7 Replies

9. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

10. UNIX for Beginners Questions & Answers

How to convert my /bin/sh script with cgi and html to run it on browser!??

Hello, I want to run this script on my CentOS 6 via browser : ________________________________________________________________________________________________ #!/bin/sh echo Username? read MY_NAME echo Provisional file name? read MY_FILE echo File NAME you want to save? read MY_FILE2... (16 Replies)
Discussion started by: juta2020
16 Replies
BIO_push(3)							      OpenSSL							       BIO_push(3)

NAME
BIO_push, BIO_pop - add and remove BIOs from a chain. SYNOPSIS
#include <openssl/bio.h> BIO * BIO_push(BIO *b,BIO *append); BIO * BIO_pop(BIO *b); DESCRIPTION
The BIO_push() function appends the BIO append to b, it returns b. BIO_pop() removes the BIO b from a chain and returns the next BIO in the chain, or NULL if there is no next BIO. The removed BIO then becomes a single BIO with no association with the original chain, it can thus be freed or attached to a different chain. NOTES
The names of these functions are perhaps a little misleading. BIO_push() joins two BIO chains whereas BIO_pop() deletes a single BIO from a chain, the deleted BIO does not need to be at the end of a chain. The process of calling BIO_push() and BIO_pop() on a BIO may have additional consequences (a control call is made to the affected BIOs) any effects will be noted in the descriptions of individual BIOs. EXAMPLES
For these examples suppose md1 and md2 are digest BIOs, b64 is a base64 BIO and f is a file BIO. If the call: BIO_push(b64, f); is made then the new chain will be b64-chain. After making the calls BIO_push(md2, b64); BIO_push(md1, md2); the new chain is md1-md2-b64-f. Data written to md1 will be digested by md1 and md2, base64 encoded and written to f. It should be noted that reading causes data to pass in the reverse direction, that is data is read from f, base64 decoded and digested by md1 and md2. If the call: BIO_pop(md2); The call will return b64 and the new chain will be md1-b64-f data can be written to md1 as before. RETURN VALUES
BIO_push() returns the end of the chain, b. BIO_pop() returns the next BIO in the chain, or NULL if there is no next BIO. SEE ALSO
TBA 50 2013-03-05 BIO_push(3)
All times are GMT -4. The time now is 09:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy