Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to attach a file in mail? Post 1761 by mib on Thursday 29th of March 2001 06:38:24 AM
Old 03-29-2001
mail -s "just to say NT carashed again" billgates@microsoft.com < mypicture.jpeg
it is not a relaible way , chances are high that the image will be unusable the time it arrives at the recipient. Smilie

another way:
(cat mailtext; uuencode mypicture.jpeg mypicture.jpeg) |
mail billgates@micro$oft.com

mailtext is provides contents for mail. The file name "mypicture.jpeg" appears twice on the uuencode command line: the first time to specify the input file name, the second time for the remote extraction file name.

but a flexible, relaible & easy way is to use <b>MetaMail</b>Package. This is the original set of MIME tools written by Nathaniel Borenstein. It works as a stand-alone set of tools for sending messages and encoding/decoding of MIME messages parts or can be set up as a plug-in for other tools. check your system before downloading metamail. new Linux distrubutions includes metamail. if you don't have try this link. after you install MetaMail Package you can use mailto or metasend. <b>metasend</b> is suitable for scripting since you could use it non-interactively.

here is an example:
metasend -b -t someone@somewhere.com -s "My webpage!" -m text/html -f mypage.html

-b batch mode (non-interactive)
-t to Recipient's address
-s subject Title (subject) of the mail message
-m MIME-type MIME content type, i.e. "text/plain", "text/html" || "application/postscript" || "image/jpeg" || "image/gif" || "video/mpeg" ....
-f filename Name of file to attach
-n Next file attachment (needed for multiple file attachments).


here is a very simple text (plain or html) attachment with just one file:
echo "From: $You\nTo: $MAILTO\nSubject: $SUBJECT\n\
Mime-Version: 1.0\nContent-Type: text/plain\n" > /tmp/file
cat MailText >> /tmp/file
/usr/lib/sendmail -t -oi < /tmp/file


above all <b>MetaMail</b> is the suitable way. isn't it?

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to attach a txt file while sending mail

Hi, I need to attach a txt file while sending mail thru Unix. Please help me out in this.. -Charan. (9 Replies)
Discussion started by: charan81
9 Replies

2. Shell Programming and Scripting

How to attach a file & send mail thru script

In shell script how can I attach a file and send a mail. suppose if I written like the following way usr/bin/mail 'subject" "mail_id" < file. a mail goes to the mail-id with the content of file.But I want the file to be atttached to the mail.How can I get it.is there any way for this. ... (9 Replies)
Discussion started by: Mar1006
9 Replies

3. UNIX for Dummies Questions & Answers

How to use "mail" to attach a file with an email?

echo "content" | mail email@address -s subject Where to attach a file with the email? (2 Replies)
Discussion started by: meili100
2 Replies

4. Shell Programming and Scripting

How to attach a file in Linux mail command

How to attach a file in Linux mail command Hi Guys, Is there any way to attach a file in Linux mail command without using "uuencode"? i.e. Code: file=/a/b/c/d/file.txtmail -s "Giga aks" abc@123.com <<HDoc`uuencode $file $file 2>/dev/null`HDoc Here, I don;t want to use 'uuencode'... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

5. HP-UX

How to attach an excel file in a multipart (mime) mail

Hello. I need to send mails from hp-ux with 2 attachments: a text file and an excel file. So I'm composing a mime file which I will pipe to sendmail utility. This works fine if the only attachment is the text file (i use cat command to attach text content). But I have problems with the format... (3 Replies)
Discussion started by: elcampio
3 Replies

6. Shell Programming and Scripting

Script to attach file to mail

Hello, I have a .dat file containing one line. I need a script to read that line and make it part of the body and send a mail... Let's say the line is $line. I need the script to send a mail with the body "The last disposal feed is $line". Thanks (4 Replies)
Discussion started by: sfetea
4 Replies

7. Shell Programming and Scripting

How to attach multiple file to send mail command

Hi, i want color effect on mail as well as multiple attachment.I have code but this code is used for single attachment. I am unable to attach more than one file.:wall: I want to send two attachments -ahmed.csv and ahmed1.csv . Sample content: <html> <body> <b> Hi...</b> </body> </html> ... (1 Reply)
Discussion started by: AhmedLakadkutta
1 Replies

8. Shell Programming and Scripting

UNIX - how to send attach excel in mail

Hi Experts, i need your help here :confused: Need to send a report thru mail using unix shell script(AIX). can you help me to do this? . i tried "uuencode" with CSV format, but while reading report all values are in single column. i need each column values in separate cell. Thanks in... (9 Replies)
Discussion started by: newbieabc
9 Replies

9. UNIX for Advanced & Expert Users

Attach a document in mail using sendmail command

Hi Guys, May i know how to attach a document using sendmail command in Linux platform.... :confused: (2 Replies)
Discussion started by: Santosh101
2 Replies

10. Shell Programming and Scripting

Unable to attach a .txt file or .log file to mail and mailx command

Hi, I am trying to attach a .log file or .txt file to mail command to send an email once my ksh script executed. I am unable to use mutt command as it has been not installed and i am not supposed to install it. I have tried many ways by googling which has not helped me to succeed. Here is my... (5 Replies)
Discussion started by: Samah
5 Replies
metasend(1)						      General Commands Manual						       metasend(1)

NAME
metasend - Crude interface for sending non-text mail SYNOPSIS
metasend [-b] [-c cc] [-F from] [-e encoding] [-f filename] [-m MIME-type] [-s subject] [-S splitsize] [-t to] [-z] [-n] [-D content- description] [-o outputfile] [-/ multipart-subtype] [-E] [-P preamble-file] DESCRIPTION
The metasend program will allow a user to send one or more pre-existing data file as non-text multimedia mail. With no arguments, the program will ask the user for the To, Subject, and CC fields. It will then ask for the name of a MIME content-type. Next, it will ask the user for the name of an existing file containing that type of data. After this, it will ask what encoding type, if any, should be applied to this data. Finally, it will ask if the user wants to include information from an additional file, in which case the last three questions will be repeated for the next file. Alternately, all of this information can be provided on the comand line, using the following options: -b -- specifies Batch (non-interactive) Mode. Will exit with an error message if all additional needed information is not provided on the command line. -c cc -- specifies the CC address -D description -- specifies a string to be used as the Content-description value -e encoding -- specifies the encoding type. Must be either "base64", "quoted-printable", "7bit", or "x-uue". "7bit" means no encoding is performed. -E -- specifies that the file being included is already a full MIME entity, and does not need to have any Content-* or other header fields added. -f filename -- specifies the file containing the data -F from -- specifies the From address -i "<content-id> -- specifies the content-id value for the MIME entity. Must be a legal content-id value, enclosed in angle brackets. -I "<content-id>" -- specifies the content-id for the multipart entity being created by metasend, if any. Must be a legal content- id value, enclosed in angle brackets. -m MIME-type -- specifies the MIME content-type -n -- specifies that an additional file is to be included. Before each use of the -n option on the command line, the options -m, -c, and -f, at a minimum, must have appeared,and must appear separately for each included file. -o outputfile -- specifies that the output from metasend should go to a named file rather than be delivered as mail. -P preamblefile -- specifies a file containing alternative text to be put in the "preamble" area of a MIME multipart message. -s subject -- specifies the Subject field -S splitsize -- specifies the maximum size before splitting into parts via splitmail(1). -t to -- specifies the To address -z -- specifies that the temporary files should be deleted EVEN IF DELIVERY FAILS. -/ subtype -- specifies the use of a MIME multipart subtype other than "mixed". This is intended largely for mail hackers. A much friendlier interface to non-text mail is provided by mailto(1). If more than one file is given, the parts will be combined into a single multipart MIME object. The mail will be delivered using the splitmail(1) program, so if it is very long it will arrive as several pieces which can be automati- cally reassembled by metamail. The definition of "very long" can be altered using the -S flag or the SPLITSIZE environment variable, as described in the splitmail(1) man page. SEE ALSO
audiosend(1), mailto-hebrew(1), mailto(1), metamail(1), mmencode(1), splitmail(1) BUGS
Should do a better job of choosing the encoding if you don't specify one. Should do MIME syntax checking on user-supplied content-type fields. Users are all too likely to provide bogus MIME content-type values, alas. In particular, there are various characters that are not allowed in parameters unless the parameters are enclosed in double quotes, but this sort of restriction is hard to enforce in a shell script! COPYRIGHT
Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) Permission to use, copy, modify, and distribute this material for any purpose and without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies, and that the name of Bellcore not be used in advertising or publicity pertaining to this material without the specific, prior written permission of an authorized representative of Bellcore. BELLCORE MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. AUTHOR
Nathaniel S. Borenstein, Bellcore Release 1 metasend(1)
All times are GMT -4. The time now is 03:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy