Unable to send attachment using mailx command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unable to send attachment using mailx command
# 1  
Old 12-04-2014
Unable to send attachment using mailx command

I am unable to send email with attachment using the mailx command. Without the attachment, the email goes through file.

This is the command I use.

Works :
Code:
 $ echo "Test" | mailx -s "Test" username@website.com

Fails :
Code:
 $echo "Test" | mailx -a all-dss-accounts.txt -s "Test" username@website.com

This is the error I get
Code:
mailx: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]

The file which I need to attach is 11 MB (is there a limit for attachment??) and it is located in the same folder from where I'm executing the command.

Help me!



Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks

Last edited by vbe; 12-04-2014 at 09:18 AM..
# 2  
Old 12-04-2014
Code:
uuencode file.txt file.txt | mailx -s ' text file attached' me@somewhere.com

Try uuencode
# 3  
Old 12-04-2014
I executed the uuencode command which you suggested.

This is the result :

Code:
./test1.sh: line 2: uuencode: command not found
Null message body; hope that's ok

SmilieSmilie
# 4  
Old 12-04-2014
Use base64 instead

Here is an example:-
Code:
(
        echo "From: from@addr.com"
        echo "To: to@addr.com"
        echo "Subject: Email Subject"
        echo "Mime-version: 1.0"
        echo "Content-Type: multipart/related; boundary=xBoundaryx"
        echo
        echo "--xBoundaryx"
        echo "Content-Type: text/plain"
        echo
        echo "Email Body"
        echo "--xBoundaryx"
        echo "Content-Type: text/plain; charset=us-ascii; name=all-dss-accounts.txt"
        echo "Content-Transfer-Encoding: base64"
        echo
        base64 all-dss-accounts.txt
) | sendmail -t -i

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to send a PDF attachment via MAILX?

Hi, We are using HPUX and have a script to send PDF attachment via MAILX Basically the script does the following: echo > $HOME/MY_mail_file uuencode o40881754.pdf o40881754.pdf >> MY_mail_file cat MY_mail_file | mailx -m -s "Sending PDF attachment" <email address> This script works... (7 Replies)
Discussion started by: Michel
7 Replies

2. Shell Programming and Scripting

Mailx command to send attachment file

Hi, I need to send a attachment which has space in the file name as: "ABC Data Extract.txt" which is present in the location /home/projects/txt i am using /home/projects/scripts mailx -s "Sub" email_id "/home/projects/txt/ABC Data Extract.txt" but i am not getting the attachment. (7 Replies)
Discussion started by: ATWC
7 Replies

3. Shell Programming and Scripting

want to send .csv file as an attachment using mailx command.

want to send .csv file as an attachment using mailx command. Please help!!! (1 Reply)
Discussion started by: gagandeep
1 Replies

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

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

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

7. UNIX for Dummies Questions & Answers

Unable to send e-mail using mailx command

Hi All, Can you please help me in solving this. I am facing some problem sending mails. If I use like this, I am able to send mail the mail echo "This is an automated e-mail; please do not reply." | mailx -s "Good Morning ." 'abc@xys.com' But if I use like this, then I am unable to send... (1 Reply)
Discussion started by: manas6
1 Replies

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

9. Shell Programming and Scripting

UNABLE to send 5MB attachment using mailx

hi, i've created a script that sends out an email using the mailx and uuencode command. the script is ok, but when a 5MB attachment is sent, there are time that the intended recepients does not receive any email. i tested it and the issue is intermitent. please help on how to troubleshoot. i... (3 Replies)
Discussion started by: tads98
3 Replies

10. Shell Programming and Scripting

HELP!!! how to send PDF file as an attachment using mailx

Hi, iam using the following command: uuencode file1.pdf file1.pdf|mailx - s "waz up?" xyz@domain.com Iam recieving an encoding error when i try to open the attachment. Pls help..very urgent!!! (1 Reply)
Discussion started by: Brat
1 Replies
Login or Register to Ask a Question