문제

내가 필요한 파일을 첨부와 mailx 그 순간에 나는 데 성공합니다.

여기 나의 코드:

subject="Something happened"
to="somebody@somewhere.com"
body="Attachment Test"
attachment=/path/to/somefile.csv

uuencode $attachment | mailx -s "$subject" "$to" << EOF

The message is ready to be sent with the following file or link attachments:

somefile.csv

Note: To protect against computer viruses, e-mail programs may prevent
sending or receiving certain types of file attachments.  Check your
e-mail security settings to determine how attachments are handled.

EOF

어떤 의견을 높게 평가될 것입니다.


업데이트 추가 첨부 파일 var 하는 것을 피하기 위해 경로를 사용하여 모든 시간입니다.

도움이 되었습니까?

해결책

당신이해야 하는 모두의 텍스트 메시지와 uuencoded 첨부:

$ subject="Something happened"
$ to="somebody@somewhere.com"
$ body="Attachment Test"
$ attachment=/path/to/somefile.csv
$
$ cat >msg.txt <<EOF
> The message is ready to be sent with the following file or link attachments:
>
> somefile.csv
>
> Note: To protect against computer viruses, e-mail programs may prevent
> sending or receiving certain types of file attachments.  Check your
> e-mail security settings to determine how attachments are handled.
>
> EOF
$ ( cat msg.txt ; uuencode $attachment somefile.csv) | mailx -s "$subject" "$to"

다른 방법이 있을 제공하는 메시지에 텍스트,이것은 단지 예는 근처 원래 질문입니다.는 경우 메시지를 재사용 그것은 단지에서 그것을 저장하는 파일과 이 파일을 사용합니다.

다른 팁

론,여기에 처음 몇 가지 문제가 당신을 가지고 있다.

  1. 당신이 나타나고 가정하면 메일 클라이언트를 처리 uuencoded 첨부 파일이 없이 헤더가 있습니다.는 일어나지 않을 것입니다.

  2. 당신이 악용하고 I/O redirection:uuencode 출력하고 여기에 문서는 모두에게 먹이로 쓰인 mailx 할 수 있는 그런 일이 없을 것입니다.

  3. 당신이 악용하 uuencode:는 경우에 하나의 경로 주어진,그것은 단지의 이름을 제공 디코딩된 파일이 아닌 입력 파일 이름입니다.을 주는 파일에 두 번 것입 할당 같은 이름을 디코딩된 파일로 되었습니다.-M 플래그 base64 인코딩.그러나 이것은 여전히지 않을 제공하는 첨부 파일의 헤더에 대한 mailx.

당신은 방법은 더 나은 사본을 받고의 mpack 것이다,당신이 무엇을 원합니다.

해야 하는 경우에는지,그것을 당신이 뭔가를 할 수 있습니다:

cat <<EOF | ( cat -; uuencode -m /path/to/somefile.csv /path/to/somefile.csv; ) | mailx -s "$subject" "$to" 
place your message from the here block in your example here
EOF

의 많은 다른 기능이 있습니다...그러나 이것은 여전히 여기에 문서 로에 예고 쉽게 떨어져 우리의 최고 있으며,임시 파일 참여합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top