send attachment and body in one mail using mailx


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting send attachment and body in one mail using mailx
# 1  
Old 06-22-2010
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 body.i want to send a message as well regarding the script name and other details in the body along with the attachment.

Can anyone help me to do that so that in one mail i can send the attachment and also some details regarding the script in body.

Thanks in advance
# 2  
Old 06-22-2010
Try using Here Document

This worked for me

Code:
 
mailx -s "$email_subject" $EmailRecipients << EOM
`uuencode $exp_file $exp_file`
 
Please find the file attached
 
Message in Body goes here.............
 
EOM

# 3  
Old 06-22-2010
Quote:
Originally Posted by ashwin3086
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 body.i want to send a message as well regarding the script name and other details in the body along with the attachment.

Can anyone help me to do that so that in one mail i can send the attachment and also some details regarding the script in body.

Thanks in advance

To add the body, you can try this:
Code:
(printf "%s\n%s\n" "$body" "$body1"; uuencode $exp_file $exp_file) |mailx -s "$email_subject" $EmailRecipients

These 4 Users Gave Thanks to Leion For This Post:
# 4  
Old 06-23-2010
Code:
mailx -s "subject" -f "attach_file" "body"

try this one out
# 5  
Old 06-24-2010
@sachin - I did try the way u told but still i wasnt getting the body of the mail.
@leion - thanks.. this is working.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mailx with attachment and message body

i have to attach the 'body in the email' along with attachment below code is throwing errors, how can i do it ? here body file contains message, it should display in email, please help i am using HP-UX (cat body ;) (uuencode attch1 attch1 ;) | mailx -m -s "testing" "abc@gmail.com" ... (4 Replies)
Discussion started by: only4satish
4 Replies

2. UNIX for Dummies Questions & Answers

Send email with attachment and body : mailx , waiting for input , signal Control D

Hi, I am trying to send email with attacment and body using "mailx" (cat body.txt; uuencode attach.txt) | mailx -s "Attachment" abc@xyz.com When i type this command, the shell is still waiting for me to enter something in standard input and press control D before it sends a mail and... (2 Replies)
Discussion started by: aliaszero
2 Replies

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

4. Shell Programming and Scripting

Mailx: How to send a attachment using mailx command

Hi All, Can anyone please provide the command for sending an mail with attachment using mailx command. Thanks in Advance :) Regards, Siram. (3 Replies)
Discussion started by: Sriram.Vedula53
3 Replies

5. UNIX for Advanced & Expert Users

how to send file as attachment using mail or mailx

I have a need to send a file from the unix command line to be sent as an attachment. Is this possible? That is when I open my outlook email I need to file to appear as an attachment. Also, is there a way to use the mail binary (not mailx) to modify the "reply address". mailx -r works but I need... (1 Reply)
Discussion started by: kieranfoley
1 Replies

6. Shell Programming and Scripting

Problem with Mailx command to send mail with attachment

Hi, I am using mailx command to send a mail with attachment. It's working fine, but with attachment I am getting one extra attachment like (ATT00131.txt). I have tried to use unix2dos command also. But still I am getting the extra attachment. I am using the following code: subject="temp... (5 Replies)
Discussion started by: viswanatharv
5 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. AIX

Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum: I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command... (3 Replies)
Discussion started by: G-Man
3 Replies

9. UNIX for Dummies Questions & Answers

AIX send mail with HTML message body and a binary attachment

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command line switch to specify file name of a binary attachment 3. command line or input file to specify... (4 Replies)
Discussion started by: G-Man
4 Replies

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