ATWC
November 12, 2014, 12:28am
1
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.
zozoo
November 12, 2014, 4:48am
2
try the below
uuencode path/'ABC Data Extract.txt' "ABC Data Extract.txt" |mailx -s "subject" xyz@abc.com
From man mailx
:
-a file
Attach the given file to the message.
Try
mailx -s "Sub" email_id -a "/home/projects/txt/ABC Data Extract.txt"
ATWC
November 12, 2014, 9:38am
4
DIR_TEMP=/home/projects/scripts
emal_sbjct_txt='ABC DEF'
Email_body.txt --> ABC
emal_id='xyz@abc.com'
dest_desc=/home/projects/txt
rpt_nm=ABC Data Extract.txt
cat "${DIR_TEMP}/Email_body.txt" | mailx -s "${emal_sbjct_txt}" ${emal_id} -a ${dest_desc}/"${rpt_nm}"
the attachment is not getting delivred.
Also the email id are not coming correctly.
If it's not correct, then what is it?
Is it a script you posted? If yes, remove or comment out this (it makes no sense there): Email_body.txt --> ABC
You need to quote the value you're assigning to a variable if the value contains whitespace(s). Try
rpt_nm="ABC Data Extract.txt"
If the command still fails, the order of the mailx options might matter, in this case try (note option -a *before* the email address):
cat "${DIR_TEMP}/Email_body.txt" | mailx -s "${emal_sbjct_txt}" -a ${dest_desc}/"${rpt_nm}" ${emal_id}
If everything fails, post your script and error messages you get.
1 Like
vbe
November 12, 2014, 10:39am
7
-a
does not exist on standard unix to my knowlege except maybe the very last release...
and may not be for attach <file> e.g. here a Debian:
-a Specify additional header fields on the command line such as "X-Loop: foo@bar" etc. You have to use
quotes if the string contains spaces. This argument may be specified more than once, the headers will
then be concatenated.
That is why we insist so much on you giving the shell you use, and the architecture / OS and OS release...
ATWC
November 12, 2014, 11:12am
8
After changing the order in mailx it worked.
Thanks you