How to send email as HTML format with attachment ?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to send email as HTML format with attachment ?
# 1  
Old 12-09-2010
How to send email as HTML format with attachment ?

hi..

Could somebody help me how to sent an attachment using sendmail command and the content is HTML format ?.

Below is my code to sent the email as HTML but i do not know how to sent the attachment, please help me

Code:
To: "BAHARIN HASAN"<baharin.hasan@gmail.com>
from: "DATAONE SDN BHD"<admin@dataone.asia>
Subject: test
Content-Type: text/html
charset="us-ascii"

<html>
<head>
<title>Your Page Title</title>
</head>

<body>
<center>
<table border=0>
  <tr>
    <th><img border=0 src=/images/pulpit.jpg alt=Pulpit rock width=67 height=92 /></th>
    <th><p>&nbsp;</p><h2>Bill Statement</h2></th>
  </tr>

  <tr>
  <td><h4>Dear <ASMAH_AHMAD>,</h4>
  <p>Thank you for your valued subscription to our<br/>
     services.Your TM bill statement is now attached as <br/>
     an Adobe PDF file in this email.</p>
  <p>Thank You</p></td>
  <td><p>Account No.</p><p><12345></p>Statement Date.<p><12/12/2010></p></td>
  </tr>
</table>
<center><img src=example.jpg alt=example/></center>
</center>
</body>
</html>

Thank you,
baharin
# 2  
Old 12-09-2010
Your "code" is an html-encoded file. There are two ways the easiest one
Code:
# assume your html-encoded file is named: t.htm
uuencode t.htm t.htm | mailx -s 'subject goes here'  somebody@yourcompany.com

The other way requires base64 encoding using perl base64. Since most machines do not have that installed already, option #1 is easier.
# 3  
Old 12-09-2010
Thank for your reply..

How about the attachment ?... is it your code will be sent the attachment ?
# 4  
Old 12-09-2010
There's no easy way to fulfill your requirements from the command line. Sending HTML emails: easy. Sending HTML emails with images and an attached PDF: not so easy. The problem is that you'll either have to provide a full URL for the images, or attach them too.

Instead of sending from the command line, I'd suggest taking a look at MIME::Lite. It even includes an example of how to send an HTML mail with images.
# 5  
Old 12-09-2010
Also suggest you look at the mutt mailer. It has a command line option (-a) to attach one or more files using MIME.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Unable to send attachment with html tables in UNIX shell script

Heyy, any help would be grateful.... LOOKING FOR THE WAYS TO SEND AN EMAIL WITH ATTACHMENT & HTML TABLES IN BODY THROUGH SHELL SCRIPT (LINUX)..NOT SURE, IF WE HAVE ANY INBUILT HTML TAG OR UNIX COMMAND TO SEND THE ATTACHMENTS. KINDLY HELP below is small script posted for our understanding..... (2 Replies)
Discussion started by: Harsha Vardhan
2 Replies

2. Shell Programming and Scripting

How to send email HTML + PDF attachment?

I am attempting to write a script where I can pass in parameters ( to , from, the location of a pdf attachment ) and send an email that has HTML for the body content and a PDF as an attachment. I have failed to achieve this with sendmail and mutt. I recently found this. If there are any... (2 Replies)
Discussion started by: jvsrvcs
2 Replies

3. Shell Programming and Scripting

Not able to send attachment with the email

Hi All, The below code is working fine for me. mailx -s hello abc@xyz.com <<EOT Hello !!! How are you? Regards Rahul EOT But i am not able to send csv file with the mail .Getting just themail but not the attachment. uuencode /path/s1.csv | mailx -s hello abc@xyz.com <<EOT... (9 Replies)
Discussion started by: rafa_fed2
9 Replies

4. UNIX for Dummies Questions & Answers

Sending html email with html attachment

Hello, I have a script which is sending an html file as an attachment. #!/usr/bin/ksh export MAILTO="user@company.com" export CONTENT="/usr/tmp/file.html" export SUBJECT="EmailSubject" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (0 Replies)
Discussion started by: sreenathkg
0 Replies

5. Shell Programming and Scripting

html format email with attachment in unix

Team, I have the below code, which is working fine and it sends the html report using sendmail command. I want to attach one more file ( which goes as attachment ) in that email. How to achieve it. i tried with uuencode. But no luck :mad: outputFile="/tmp/out.html" ( echo... (2 Replies)
Discussion started by: itkamaraj
2 Replies

6. Shell Programming and Scripting

Unable to send mail with inline html along with attachment. Please help!

The below code is not working. I am able to send only inline html or only attachment. When trying to do both, only inline html is sent without attachment. Please help! #!/bin/ksh (echo "Subject: Test Mail - HTML Format" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

7. 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

8. Shell Programming and Scripting

unable to send an email attachment

i know its pretty repeated query, but i need to post it in this new thread coz i need it urgently uuencode /var/tmp/chandra/emaillist.txt emaillist.txt | mail -s "message with encoded attachment" am unable to send the attachment emaillist.txt present in the path /var/tmp/chandra/ Is... (11 Replies)
Discussion started by: cmaroju
11 Replies

9. UNIX for Dummies Questions & Answers

AIX send mail with HTML message body and a binary attachment

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command line switch to specify file name of a binary attachment 3. command line or input file to specify... (4 Replies)
Discussion started by: G-Man
4 Replies

10. Shell Programming and Scripting

Send an attachment and html text both in the same mail

Hi all, I am working on UNIX (Solaris28). I would like to send an email in which the body will be in html format and, in the same mail, a xls file has to be attached. I have tried this: the file is correctly attached but the body comes as html source and not formatted. If I do not attach the... (4 Replies)
Discussion started by: stefan.yu
4 Replies
Login or Register to Ask a Question