简体   繁体   中英

Shell Script - Unix - mailx

I'm having this problem when I send an email from Unix with the below commands :

uuencode data.js.txt data.js.txt | mailx -r "From" -s "someSubject" "To@gmail.com"

So the issue here is when I receive the email , I don't get the attachment correctly .

I receive it like this :

begin 664 data.js.txt

M=F%R(%120E]0,3`@/2!;(C`T+3`W+3$V(#`X.C`P.C0T(S`C,",C(BPB,#0M
M,#<M,38@,#DZ,#`Z-3`C,",P(R,B+"(P-"TP-RTQ-B`Q,#HP,#HU-B,P(S`C
M(R(L(C`T+3`W+3$V(#$Q.C`P.C$P(S`C,",C(BPB,#0M,#<M,38@,3(Z,#`Z
M-3$C,",P(R,B+"(P-"TP-RTQ-B`Q,SHP,#HP-B,P(S`C(R(L(C`T+3`W+3$V
M(#$T.C`P.C$V(S`C,",C(BPB,#0M,#<M,38@,34Z,#`Z,S,C,",P(R,B+"(P
M-"TP-RTQ-B`Q-CHP,#HT,B,P(S`C(R(L(C`T+3`W+3$V(#$W.C`P.C4P(S`C
M,",C(BPB,#0M,#<M,38@,3@Z,#$Z,#`C,",P(R,B+"(P-"TP-RTQ-B`Q.3HP
M,#HQ,R,P(S`C(R(L(C`T+3`W+3$V(#(P.C`P.C(P(S`C,",C(BPB,#0M,#<M

When I send the file like this :

uuencode ${filename} ${filename} | mailx -r $FROM -m $TO

I will have no problems with the file , but i need a subject in my mail .

What can I do :( ?

Well I have found the solution :

(
cat << !
From : ${FROM}
To : ${TO}
Subject : ${SUBJ}
!
uuencode ${filename} ${filename}

) | /usr/sbin/sendmail -f $FROM -v $TO

This option worked perfect .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM