Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Sending html email with html attachment Post 302608129 by sreenathkg on Friday 16th of March 2012 10:18:02 AM
Old 03-16-2012
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 "Content-Disposition: inline"
cat $CONTENT
) | /usr/sbin/sendmail $MAILTO


I have another script which will send the content of this html file as body of the email.


unset LC_CTYPE
uuencode /usr/tmp/file.html file.html | mailx -m -s "EmailSubject" "user@company.com"



Both these scripts working perfectly. But I need to get both this combined and send a single email with attachment and same file content as body also.

I saw several posts here but no help.... Please help me!!!!

---------- Post updated at 07:35 PM ---------- Previous update was at 06:36 PM ----------

Wow I got the answer from here itself...


outputFile="/usr/tmp/file.html"
attachFile="/usr/tmp/file.html"
(
#echo "From: sendername"
echo "To: user@company.com"
echo "Subject: EmailSubject"
echo "Mime-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="GvXjxJ+pjyke8COw"'
echo "Content-Disposition: inline"
echo ""
echo "--GvXjxJ+pjyke8COw"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $outputFile
echo ""
echo "--GvXjxJ+pjyke8COw"
echo "Content-Type: text/plain"
echo "Content-Disposition: attachement; filename=file.html"
echo ""
cat $attachFile
) | /usr/lib/sendmail -t



Thanks to Jayan_Jay

---------- Post updated at 07:47 PM ---------- Previous update was at 07:35 PM ----------

But this one removes the header part from body. But in attachment the header is available. Smilie

---------- Post updated at 07:48 PM ---------- Previous update was at 07:47 PM ----------

But this one removes the header part from body. But in attachment the header is available. Smilie

Last edited by sreenathkg; 03-16-2012 at 10:21 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending HTML attachment through mail

Hi I am new to unix and scripting.I am trying to send a html file as an attachment. SUBJECT="Type of Exceptions in Application" TO=Sushovan.Samals@gmail.com SPOOLFILE=/data/reg/tlogs/Monitor.html #echo "Send the E-mail message..." uuencode $SPOOLFILE $SPOOLFILE | mailx -s "$SUBJECT" $TO... (2 Replies)
Discussion started by: sushovan
2 Replies

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

3. UNIX for Advanced & Expert Users

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 To: "BAHARIN HASAN"<baharin.hasan@gmail.com> from: "DATAONE SDN... (4 Replies)
Discussion started by: bh_hensem
4 Replies

4. Shell Programming and Scripting

Problem in sending inline html with an attachment using sendmail

MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=border --border Content-Type: text/html Content-Disposition: inline <html><body><h2>This text should be displayed with html formatting</h2></body></html> --border Content-Type: text/plain Content-Disposition: attachment This text... (2 Replies)
Discussion started by: thulasidharan2k
2 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

Sending HTML Email through mailx

Hi, I am trying to send html email using mailx like follow on sh shell (Bourne) on HP-UX: mailx -s "Test HTML output in outlook MIME-Version: 1.0 Content-Type: text/html" receiver@host.com < file.txt Content of file.txt are as follows: <html> <h2>An important link to look at!</h2>... (3 Replies)
Discussion started by: manubatham20
3 Replies

7. Shell Programming and Scripting

Sending a csv attachment and html text together.

Hello, I need to send below text (in a file ABC)as html text in mail body and the same as csv attachment 1,2,3 4,5,6 7,8,9 but to send as html text in mailbody we use echo "Subject: Report " | cat - ABC | /usr/lib/sendmail -t a@xyz.com and to send as an attachment in csv format we... (9 Replies)
Discussion started by: skhichi
9 Replies

8. Shell Programming and Scripting

Sending HTML Email

1) Can you please provide me with a best example of how to send an HTML email via mutt or mail or send email commands using bash shell. 2) I tried below but i am not able to get the variable values in the HTML email output. (cat <<-EOT <html> <head><title></title> </head> <body> <p>Hello,... (9 Replies)
Discussion started by: Ariean
9 Replies

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

10. Shell Programming and Scripting

Need help in sending html mail with attachment

Hi Everyone, I am facing problems in sending html mail with attachemnt. I will able to send mail with attachment (plain text ) using mailx -s and uuencode command and also html mail without attachment using sendmail option. However I am not able to send html mail along with attachment.Either... (2 Replies)
Discussion started by: karthik adiga
2 Replies
ftpmail(1)						      General Commands Manual							ftpmail(1)

NAME
ftpmail - FIFO-based Perl script for sending email based on proftpd TransferLog SYNOPSIS
ftpmail [ --help ] [ --fifo fifo-path ] [ --from email-address ] [ --log xferlog-file ] [ --recipient email-address ] [ --subject email- subject ] [ --smtp-server server-address ] [ --attach-file ] [ --auth smtp-auth-info-file ] [ --ignore-users regex-pattern ] [ --watch- users regex-pattern ] DESCRIPTION
ftpmail is a Perl script designed to read ProFTPD's TransferLog log entries, watching for uploads, and to send an automatic email notifica- tion when uploads occur. To use ftpmail , you configure your proftpd daemon to write its TransferLog to a FIFO; the ftpmail program is a FIFO reading program which then processes those log messages. OPTIONS
--help Display a short usage description, including all available options. --attach-file If used, this will cause a copy of the uploaded file to be included, as an attachment, in the generated email. --auth smtp-auth-info-file Configures the path to a file containing SMTP authentication information. The configured file should look like this: user username password password --fifo fifo-path Indicates the path to the FIFO to which proftpd is writing its TransferLog. That is, this is the path that you used for the TransferLog directive in your proftpd.conf. This parameter is REQUIRED. --from email-address Specifies the email address to use in the From email header. This parameter is REQUIRED. --ignore-users regex-pattern Specifies a Perl regular expression. If the uploading user name matches this regular expression, then an email notification is NOT sent; otherwise, an email is sent. --log xferlog-path Since this script reads the TransferLog using FIFOs, the actual TransferLog file is not written by default. Use this option to write the normal TransferLog file, in addition to watching for uploads. --recipient email-address Specifies an email address to which to send an email notification of the upload. This option can be used multiple times to specify multiple recipients. AT LEAST ONE recipient is REQUIRED. --smtp-server server-address Specifies the SMTP server to which to send the email. This parameter is REQUIRED. --subject subject Specify a custom Subject email header for the email sent. The default Subject is: User '$user' uploaded file '$file' via FTP --watch-users regex-pattern Specifies a Perl regular expression. If the uploading user name matches this regular expression, then an email notification is sent; otherwise, no email is sent. FILES
/var/log/xferlog AUTHORS
ProFTPD is written and maintained by a number of people, full credits can be found on http://www.proftpd.org/credits.html SEE ALSO
proftpd(8), xferlog(5) Full documentation on ProFTPD, including configuration and FAQs, is available at http://www.proftpd.org/ For help/support, try the ProFTPD mailing lists, detailed on http://www.proftpd.org/lists.html Report bugs at http://bugs.proftpd.org/ March 2011 ftpmail(1)
All times are GMT -4. The time now is 10:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy