Sendmail with header and footer logo in HTML body


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sendmail with header and footer logo in HTML body
# 8  
Old 05-09-2013
Here is a code that I wrote for sending:
  • HTML mail body
  • 1 JPEG file inline (not attachment)
  • 1 GIF file inline (not attachment)
Please note the MIME headers that I used:
Code:
{
        echo "From: from@domain.com"
        echo "To: to@domain.com"
        echo "MIME-Version: 1.0"
        echo "Subject: Email Subject"
        echo "Content-Type: multipart/mixed; boundary=\"FILEBOUNDARY\""


        echo "--FILEBOUNDARY"
        echo "Content-Type: multipart/alternative; boundary=\"MSGBOUNDARY\""


        echo "--MSGBOUNDARY"
        echo "Content-Type: text/html; charset=iso-8859-1"
        echo "Content-Disposition: inline"
        echo "<html><body>"
        echo "<font face=verdana size=2>Header Image</font><br>"
        echo "<img src=\"cid:myjpeg\" /><br>"

        echo "<font face=verdana size=2>Footer Image</font><br>"
        echo "<img src=\"cid:mygif\" /><br>"
        echo "</body></html>"
        echo "--MSGBOUNDARY--"


        echo "--FILEBOUNDARY"
        echo "Content-Type: image/jpeg"
        echo "Content-Disposition: inline; filename=\"image_1.jpg\""
        echo "Content-Transfer-Encoding: uuencode"
        echo "Content-Id: <myjpeg>"
        uuencode image_1.jpg image_1.jpg


        echo "--FILEBOUNDARY"
        echo "Content-Type: image/gif"
        echo "Content-Disposition: inline; filename=\"image_2.gif\""
        echo "Content-Transfer-Encoding: uuencode"
        echo "Content-Id: <mygif>"
        uuencode image_2.gif image_2.gif
        echo "--FILEBOUNDARY--"

} | /usr/lib/sendmail -t

Modify as per your requirement. I hope this helps.
This User Gave Thanks to Yoda For This Post:
# 9  
Old 05-10-2013
Hello Yoda,

Good morning!

Very much appreciated your prompt reply on my post yesterday. I'll try your suggested solution and we'll keep you posted.

Thanks much.

Cheers,

JL

---------- Post updated at 12:42 PM ---------- Previous update was at 11:13 AM ----------

Hi Yoda,

You're a GENIUS! It's worked! flawlessly :-)

I'm currently working now on html file without hardcoding the html code within the bash script. Because when I cat the html file WITHIN it doesn't shows both the jpg and gif file. Hope I'll be able to figure this out.

Once again, thank you very much for your help.

sidenote: I close this post as RESOLVED.

Cheers,

JL

Last edited by lawrence88; 05-10-2013 at 05:25 PM..
This User Gave Thanks to lawrence88 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail cmd for html body and attachment not working

Hi, I am having trouble in sending a mail with html body and attachment (csv file). We don't have uuencode or mutt (not allowed to install as well) The below code is perfectly working for sending the html body alone: export MAILTO=abc@xyz.com export CONTENT="/home/abc/list.html"... (2 Replies)
Discussion started by: close2jay
2 Replies

2. UNIX for Dummies Questions & Answers

Sendmail with HTML body and attachment code issues

Hi, I was working on getting an HTML file in the mail body along with attaching a "csv" file to the mail. Below are the 2 parts of the code. I need help with the second part where I'm sending the mail. The HTML file as an attachment is perfect without any issues and with proper formatting.... (6 Replies)
Discussion started by: aster007
6 Replies

3. Shell Programming and Scripting

Email body not formatted with html and sendmail

Hi All, I am trying to send the contents of a file as email body. I am using html email and sendmail option of unix. I am using the below piece of code for the same : #!/usr/bin/ksh export MAILTO="email@domain.com" export SUBJECT="Report" export BODY="file_directory_path/test_file.txt"... (1 Reply)
Discussion started by: rockygsd
1 Replies

4. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

5. Shell Programming and Scripting

Add header and footer with record count in footer

This is my file(Target.txt) name|age|locaction abc|23|del xyz|24|mum jkl|25|kol The file should be like this 1|03252012 1|name|age|location 2|abc|23|del 2|xyz|24|mum 2|jkl|25|kol 2|kkk|26|hyd 3|4 Column 1 is row indicator for row 1 and 2, column indicator is 1,for data rows... (1 Reply)
Discussion started by: itsranjan
1 Replies

6. Shell Programming and Scripting

Header and Footer...

Hi All, I need to write a script that In my file I have to check header and footer records are available or not. If it is available I have to run the script, otherwise I should not. But current script it is checking only the data inside the script. It is avoiding to check Header and Footer... (1 Reply)
Discussion started by: suresh_target
1 Replies

7. Shell Programming and Scripting

Sendmail with HTML body and attachment

I have an HTML file I am currently sending in the body of an email. I now have a need to send a csv attachment along with it. I can ONLY use sendmail as mutt and xmail etc are not on the server. Here is what I am currently using: It is possible to add code to add an attachment ??!? { ... (8 Replies)
Discussion started by: atelford
8 Replies

8. Red Hat

Send HTML body and HTML attachment using MUTT command

Hi there.. I need a proper "mutt" command to send a mail with html body and html attachment at a time. Also if possible let me know the other commands to do this task. Please help me.. (2 Replies)
Discussion started by: vickramshetty
2 Replies

9. Shell Programming and Scripting

Sendmail with html attachment and html body

Hi folks, I have a perl script which sends out email after successful completion of job as inline html, I want to send it out as two parts now as html inline and html attachment. see the attached script. Thanks in advance (1 Reply)
Discussion started by: sol_nov
1 Replies

10. Shell Programming and Scripting

Inserting Header and footer

Hi All, I have several txt files i need to enter specific header and footer (both are separate) to all these files how can i do this? plz help.. Regards, Raghav (4 Replies)
Discussion started by: digitalrg
4 Replies
Login or Register to Ask a Question