Operating System - HP-UX
1834906 Members
2567 Online
110071 Solutions
New Discussion

Re: script send email attachment

 
kholikt
Super Advisor

script send email attachment

I am writing a script to send me a report file as attachment. This file is in pdf format. What should be content-type and enconding I should specify.

function func_send_email
{
(
echo "Content-Type: multipart/mixed"
echo "Content-Transfer-Encoding: 8bit"
echo "From:$SEND_FROM"
echo "To:$1"
echo "Subject: $REPORT_TITLE"
cat < $2
) | /usr/sbin/sendmail -t
}
abc
9 REPLIES 9
A. Clay Stephenson
Acclaimed Contributor

Re: script send email attachment

One of the easiest and most powerful ways to do this via elm from the command line using the [include] syntax. Multiple attachments with mail text in between is very easy.


Within the body of your email add this:

------------------------------------

This is my text. How are you?


[include /tmp/myattach application/octet-stream base64]

This is some more text in the middle.

[include /tmp/myexcel.xls application/ms-excel base64]

This is a closing message in the email.

----------------------------------------



That will attach /tmp/myattach and /tmp/myexcel.xls. You can include multiple attachments using this method.


Then to use it from a script:
elm -s "My Subject" user@mailserver.com < myletter

Where myletter contains the attachment include statement(s) as well as your message text. It is also necessary that you have a .elm directory
under the senders home directory because unlike the interactive version of elm the command-line version will not create a .elm directory automatically.

If it ain't broke, I can fix that.
Vibhor Kumar Agarwal
Esteemed Contributor

Re: script send email attachment

Try uuencode.
Vibhor Kumar Agarwal
morganelan
Trusted Contributor

Re: script send email attachment

Try use:
Content-Type: application/pdf
Kamal Mirdad
Luk Vandenbussche
Honored Contributor

Re: script send email attachment

Hi,

I am using the email client mutt for this

http://hpux.connect.org.uk/hppd/hpux/Networking/Mail/mutt-1.5.9/

This is a script to send mail with mutt

DESTIN=your.email@company.com
SUBJECT="mail from unix server"
ATTACH1="/etc/passwd"
ATTACH2="/etc/hosts"
TEXTFILE=/etc/inittab

/usr/local/bin/mutt -a "$ATTACH1" -a "$ATTACH2" -i "$TEXFILE" -s
"$SUBJECT" $DESTIN << EOF >/dev/null 2>&1
EOF

You don't need to work with uuencode and uudecode
John Waller
Esteemed Contributor

Re: script send email attachment

I've attached a script I found on this forum I've called mail_files. Instructions on how to use the script are included at the top of the file.
Muthukumar_5
Honored Contributor

Re: script send email attachment

Use as Content-type: application/pdf

hth.
Easy to suggest when don't know about the problem!
Steven E. Protter
Exalted Contributor

Re: script send email attachment

http://www.hpux.ws/mailfile2

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Raj D.
Honored Contributor

Re: script send email attachment

Hi Kholikt,

You can include this line to send the attachment with email..


uuencode filename.ext filename.ext | mailx -s "Attached file from unix" yoruemail@domain.com

Enjoy ,
Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Manuel Contreras
Regular Advisor

Re: script send email attachment

another that uses mutt...works like a charm.

install on your box, and never look back.