Not able to attach text in body of email while sending mail with attachment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Not able to attach text in body of email while sending mail with attachment
# 1  
Old 05-05-2010
Not able to attach text in body of email while sending mail with attachment

Hi,

We have been trying to send mail with attachment and it is going fine, but when we try to attach a text to the body of the email, we find that the mail is going fine with the body text but the attachment is not going through. We are using ksh.

The command that is successfull without the body of text is;
Code:
uuencode sourcefile sendfile | mailx -s "Test" -r email1@.com email2@.com

The following command sends the mail with the body text but not attachment;
Code:
 
uuencode sourcefile sendfile | mailx -s "Test" -r email1@.com email2@.com < test.txt

In the second command the "test.txt" file has the body text of the mail.

We would like to send mail with attachment and with some text in the body of the mail.

Can someone help me in this case. Thanks in advance.
# 2  
Old 05-05-2010
Code:
( echo "some msg" ; uuencode sourcefile sendfile ) | mailx .....

# 3  
Old 05-05-2010
try this,

Code:
( cat mesgfile ; uuencode Test.dat Test.dat ) | mailx -s 'Testing' mymail@yahoo.com

# 4  
Old 05-05-2010
Code:
( cat test.txt ; uuencode sourcefile sendfile ) | mailx -s "Test" -r email1@.com email2@.com

This will work for you.However if you get difficulty in getting the attachments through cron , do let know.

Gaurav
UNIX IN BLOOD !!

Last edited by Franklin52; 05-05-2010 at 09:58 AM.. Reason: Please use code tags, thank you
# 5  
Old 05-05-2010
Thanks - it worked!!

Hi,

Thanks Pravin and Gaurav, the code given below worked fine. Thanks a lot for this help.

Quote:
Originally Posted by gauravgarg
( cat test.txt ; uuencode sourcefile sendfile ) | mailx -s "Test" -r email1@.com email2@.com

This will work for you.However if you get difficulty in getting the attachments through cron , do let know.

Gaurav
UNIX IN BLOOD !!
# 6  
Old 05-06-2010
Need to give color to text in mail sent from unix

Hi,

Pravin/Gaurav,

I am able to send a mail successfully from unix with the following script;

Code:
 
(echo "From: $REPLY"
echo "To: $DLIST"
echo "Cc: $DLIST_CC"
echo "subject: $DESCR1"
echo "$DESCR2"
echo ""
echo "$DESCR3"
echo ""
cat $CONNREP) | sendmail $DLIST

The data which is included in the mail from "cat $CONNREP" is from a file and I would like this to be in a different color like Blue or Red. Is this possible from Unix.

Sorry to bother you with this question as I could not get a satisfying answer from elsewhere.
# 7  
Old 05-07-2010
Hi,

Try the following syntax :
Code:
FGRED=`echo "\033[31m"`
FGCYAN=`echo "\033[36m"`
BGRED=`echo "\033[41m"`
FGBLUE=`echo "\033[35m"`
NORMAL=`echo "\033[m"`

and after :
Code:
echo "${FGBLUE} Text in blue ${NORMAL}"
echo "Text normal"
echo "${BGRED} Background in red"
etc...
 
echo "${FGBLUE} Text in blue ${NORMAL}"


Last edited by Scott; 05-07-2010 at 07:17 AM.. Reason: Code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Sending email with message body and attachment

Hello experts!! I am trying to send an email with message body and attachment.but i am getting any one like message body or attachment. I tried below command: (echo "subject:test";echo "MIME-Version: 1.0";echo "content-transfer-encoding:base 64";echo "content-type:txt;name=test.txt";cat... (2 Replies)
Discussion started by: Devipriya Ch
2 Replies

2. Shell Programming and Scripting

Sending an email with mail function shows up as an attachment 'noname'

I have a file named email.html with this as the contents: Content-type: text/html ACHI,ACCRETIVE HEALTH ,7.15,<br>CPRT,Copart Inc.,36.14,<br>GEOB.MX,GEO-B,1.660,<br>GCO,Genesco Inc. Comm,73.58,<br>GMAN,Gordmans Stores, ,<br>GES,Guess? Inc. Comm,26.45,<br>KBR,KBR Inc. Common... (1 Reply)
Discussion started by: phpchick
1 Replies

3. UNIX for Dummies Questions & Answers

Sending mail in UNIX with body and attachment(.txt) using sendmail command

Hi All, In my .ksh script, I am sending an email with body and attachment (.txt) using sendmail command. I am able to receive the attachement along with the body of the mail. But I am getting special characters along with the content in the .txt. Also the alignment is incorrect. Can you please... (7 Replies)
Discussion started by: KRR
7 Replies

4. UNIX for Dummies Questions & Answers

Sending email with attachment and body

Hi I want to able to attach a file to a email and send it with a body the body of the email is within the "body" file, and the attachment in "atch" if i send like below it will send the email correctly /usr/sbin/sendmail me@you.com< body And when i send the attachment alone... (3 Replies)
Discussion started by: sridanu
3 Replies

5. Shell Programming and Scripting

unix mail body with attachment

How can I send mail with attachment in HP-UX I am able to send mail with specific body,but not successful while attaching a file. I am using the below command however it stuck : uuencode test.txt |mailx -s "Subject" <e-mail id> (5 Replies)
Discussion started by: gautamadak
5 Replies

6. Shell Programming and Scripting

send attachment and body in one mail using mailx

Hi, Our requirement is to send an attachment and content in a single mail. I am using the below command to send attachement. --------------------- (uuencode $exp_file $exp_file) |mailx -s "$email_subject" $EmailRecipients -------------------- I m not able to send any message in the... (4 Replies)
Discussion started by: ashwin3086
4 Replies

7. Shell Programming and Scripting

how to send an email with some body content and attachment

hi plz help me in sending a mail with some data in body and an attachment as some txt file. currently i am able to send mail with some body content, i need an example how to send the same along with attachment. thanks in advance -bali (2 Replies)
Discussion started by: balireddy_77
2 Replies

8. Shell Programming and Scripting

Sending email with text & attachment using mailx

I spent some time working this out, with a little help from various forums, and thought the community would like to know : Here is how you can send an email from a single Unix command line : /usr/bin/echo "Email text\nNew line\nAnother new line" >x | uuencode sourcefile.txt sourcefile.txt |... (3 Replies)
Discussion started by: haryadoon
3 Replies

9. UNIX for Advanced & Expert Users

sending mails with attachment and also some text in mail body

Hi, Can some one help me with the syntax of the mailx that should send an attachment and also some text in the message body together. When I am using the following syntax it is not sending the attachment but only the message body. unix2dos -ascii $REPORTFILE | uuencode $PCFILE | mailx -s... (7 Replies)
Discussion started by: guptan
7 Replies

10. 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
Login or Register to Ask a Question