1832564 Members
5634 Online
110043 Solutions
New Discussion

sendmail attachment

 
SOLVED
Go to solution
Jeff Hagstrom
Regular Advisor

sendmail attachment

How do I attach a text file using send mail at the prompt?
sendmail -v jsmith@aol.com ............
10 REPLIES 10
Uday_S_Ankolekar
Honored Contributor

Re: sendmail attachment

uuencode file to be attach filename | sendmail email id

For example if yount to attach /etchosts file then

uuencode /etc/hosts hosts.hostname | sendmail jsmith@aol.com

-USA..
Good Luck..
someone_4
Honored Contributor
Solution

Re: sendmail attachment

Hi Jeff ,

Try

elm -s "subject" user@host < attach.file

or

uuencode [filename] [name you want for attachment] | sendmail xyz@abc.com


There are several links on theese and other ways to do it. I am sure we will get a few more on this post. But thoose two always worked for me.


~ Richard
S.K. Chan
Honored Contributor

Re: sendmail attachment

$ uuencode myfile myfile.coded | sendmail -v jsmith@aol.com

Check this thread too .. just a few days back ..

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xd81f36e69499d611abdb0090277a778c,00.html
someone_4
Honored Contributor

Re: sendmail attachment

My elm example was wrong. =(

Follow this link and look at
Ms. Workman's example.

http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0x41950559ff7cd4118fef0090279cd0f9,00.html


~ Richard
MANOJ SRIVASTAVA
Honored Contributor

Re: sendmail attachment

Hi Jeff


Ther are lots of ways to do it , elm is pretty standard one , you can download stuff like mpack to do the same thing . You may like to look at this :
http://www.stokely.com/unix.sysadm.resources/email.html#attachment.link


Manoj Srivastava
Jeff Hagstrom
Regular Advisor

Re: sendmail attachment

Richard, the elm actually worked, it took the contents of the file and put it in the body of the email. It is there a way to make a true attachment?
someone_4
Honored Contributor

Re: sendmail attachment

hi Jeff,

The link I pointed you to in my last post has a great example on how to make it a true attachment using elm. Here is the example that Rita gives.

*******************************************
if your trying to attach a file and send the file via sendmail as an attachment than you can do this also.
First make sure you at least have Elm 2.4 on your box, and my example is for a HPUX 10.2 (you need MIME capability) so be sure you have patch PHNE_15835 (it doesn't cause a reboot to load). To give you an example I ftp'd an excel spreadsheet to my box called test.xls Then I did the following:
First create a dummy file with the following line (just as you see it here)
[include test.xls application/msexcel base64]

Second from the command line:
elm -s "This is a test" user@hp.com ============================================

What this did was email to user@hp.com the file test.xls (and it comes as attached excel file) with a subject line of This is a test.
You can do it with text files; image.jpg or gif files; and more. It's a very handy tool that programmers can add right into the job streams and email reports to users instead of
printing them....makes for paperless environment.

Here's an example for a simple text file:
.. just change your include to read something like this:
[include error.file text/plain base64]


~Richard
Justo Exposito
Esteemed Contributor

Re: sendmail attachment

Hi Jeff,

Try with uuencode as tell you Uday, this works fine like an attachment.

If you want to send a body and various files attached, you can do:

cat yourbodyfile >> fich
uuencode atch_file1 atch_file1 >> fich
uuencode atch_file2 atch_file2 >> fich
....
cat fich | mailx -s "subject" jsmith@aol.com

This works fine for me.

Regards,

Justo.
Help is a Beatiful word
Don Yeske
Occasional Advisor

Re: sendmail attachment

Hi there,

I would suggest using mutt (available from the HP-UX porting and archive centre) to send mail w/ attachments from the command prompt. There is an interactive version of this command (just type mutt), but you can also send mail with attachments directly from the command line. The general syntax for this operation would be:

# cat body.txt | mutt -a "attachment.doc" -s "Subject of message" person@company.com

(where body.txt is a text file containing the body text of the message you wish to send, and attachment.doc is the file you wish to attach).

There are a couple of nice things about this solution:

1) mutt is powerful and easy-to-use
2) mail sent in this manner is MIME encoded with the correct Content-type settings.
3) mutt is rapidly becoming the mail client of choice among various UNIX implementations, so it would be a good thing to know...

Hope this helps,

- Don
Darrell Allen
Honored Contributor

Re: sendmail attachment

Hi Jeff,

I had the same problem with the text file being sent in the body instead of as an attachment. My solution was to lie. I specify the file like this:
[include text.txt application/octet-stream base64]

Haven't had the problem since.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)