代码之家  ›  专栏  ›  技术社区  ›  Nano Taboada

发送带有mailx和uuencode的附件的kornshell(ksh)代码?

  •  3
  • Nano Taboada  · 技术社区  · 17 年前

    我需要在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以避免每次都使用路径。

    2 回复  |  直到 17 年前
        1
  •  3
  •   Palmin    17 年前

    $ 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"
    

        2
  •  1
  •   Thomas Kammeyer    17 年前

    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