Professional Web Applications Themes

*attaching* a file to /usr/bin/mail message - FreeBSD

Does anyone happen to know how you would *attach* *not readin the contents of, but actually *attach*) a file using /usr/bin/mail? On my system mail has no "-a" (attach) flag, and some Googling told me mailx might solve the problem, but /usr/bin/mailx just invokes mail.... Regards & TIA, -Colin...

  1. #1

    Default *attaching* a file to /usr/bin/mail message

    Does anyone happen to know how you would *attach* *not readin the
    contents of, but actually *attach*) a file using /usr/bin/mail?

    On my system mail has no "-a" (attach) flag, and some Googling told me
    mailx might solve the problem, but /usr/bin/mailx just invokes mail....

    Regards & TIA,
    -Colin
    Colin Guest

  2. #2

    Default Re: *attaching* a file to /usr/bin/mail message

    On 2005-04-02 14:08, "Colin J. Raven" <kozy-kabin.nl> wrote: 

    Not very easily, is one answer. You can probably get away with uuencode
    output filtered to the standard input of mail(1), but that's not really
    a "MIME attachment".
     

    Other mail user agents do have a -a flag though. At least mail/mutt
    does and I've used it successfully in the past. If you are not stuck
    with mail(1) only, you can always use mutt for this.

    mutt -a /path/to/file net

    Giorgos Guest

  3. #3

    Default Re: *attaching* a file to /usr/bin/mail message

    On Apr 2 at 15:47, Giorgos Keramidas launched this into the bitstream:
     
    >
    > Not very easily, is one answer. You can probably get away with uuencode
    > output filtered to the standard input of mail(1), but that's not really
    > a "MIME attachment".

    >
    > Other mail user agents do have a -a flag though. At least mail/mutt
    > does and I've used it successfully in the past. If you are not stuck
    > with mail(1) only, you can always use mutt for this.
    >
    > mutt -a /path/to/file net[/ref]

    I'm not stuck with mail, I use it with some shell scripts....but yeah, I
    guess I could use mutt....there's an idea I hadn't previously
    considered.

    Thanks!!!

    Regards,
    -Colin
    Colin Guest

  4. #4

    Default Re: *attaching* a file to /usr/bin/mail message

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2005-04-02, Colin J. Raven scribbled these
    curious markings: 

    If you're doing scripting, why not use an actual scripting language, and
    some tools actually designed to do what you're trying to do? For
    example, Perl has MIME::Lite, which does exactly what you want -- and
    not much else. I've used it to automate sending email based on the
    output of "make test".

    Best Regards,
    Christopher Nehren
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.0 (FreeBSD)

    iD8DBQFCTtoGk/lo7zvzJioRArQJAJ9JC2uM3P7+vHtChU3qhV/c0GBbIACgnObf
    JXdlF8zucP10wfTfZGl5kDE=
    =sflC
    -----END PGP SIGNATURE-----

    --
    I abhor a system designed for the "user", if that word is a coded
    pejorative meaning "stupid and unsophisticated". -- Ken Thompson
    If you ask the wrong questions, you get answers like "42" and "God".
    Unix is user friendly. However, it isn't idiot friendly.

    Christopher Guest

  5. #5

    Default Re: *attaching* a file to /usr/bin/mail message

    > On 2005-04-02 14:08, "Colin J. Raven" <kozy-kabin.nl> wrote: 
    >
    > Not very easily, is one answer. You can probably get away with uuencode
    > output filtered to the standard input of mail(1), but that's not really
    > a "MIME attachment".[/ref]

    Okay, if you really want to use mail, here is what a mail message
    (suitable for sending through /usr/bin/mail looks like when it has a
    UUEncoded attachement. Technically you are supposed to MIME-Encode the
    attachment but pretty much every mail client that supports attachments
    will read a UUEncoded attachment.

    From: "System Administrator"<com>
    To: "test user"<com>
    Subject: Testing mail attachments.
    Content-Type: multipart/mixed;
    boundary="This_can_not_match_any_other_line_in_the _message"
    MIME-Verion: 1.0

    --This_can_not_match_any_other_line_in_the_message
    Content-Transfer-Encoding: quoted-printable
    Content-type: text/plain

    Hi, Attached is a simple text file to test multi-part sending. The file was
    originally called sample.txt and was created on a SUN system.

    Notice the string specified in the boundary="..." bit in the headers. That
    string should not occur anywhere in the body except as part of the mime
    part delimitters.

    --This_can_not_match_any_other_line_in_the_message
    Content-Transfer-Encoding: x-uuencode
    Content-Type: text/plain;
    name="sample.txt"
    Content-Disposition: attachment;
    filename="sample.txt"



    --This_can_not_match_any_other_line_in_the_message--

    You use it like this:

    /usr/bin/mail com < mail_with_attachment.txt

    Obviously, you will have to uuencode your own attachment and replace the
    one from the example.
     
    >
    > Other mail user agents do have a -a flag though. At least mail/mutt
    > does and I've used it successfully in the past. If you are not stuck
    > with mail(1) only, you can always use mutt for this.
    >
    > mutt -a /path/to/file net
    >
    > _______________________________________________
    > org mailing list
    > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    > To unsubscribe, send any mail to
    > "org"
    >[/ref]


    --
    Ean Kingston
    E-Mail: ean_AT_hedron_DOT_org
    PGP KeyID: 1024D/CBC5D6BB
    URL: http://www.hedron.org/


    Ean Guest

  6. #6

    Default Re: *attaching* a file to /usr/bin/mail message

    In article <kozy-kabin.nl>, Colin J Raven (cjr) writes:

    cjr> Does anyone happen to know how you would *attach* *not readin the
    cjr> contents of, but actually *attach*) a file using /usr/bin/mail?

    The metamail package includes metasend, a script which will build a
    MIME message you can then send to bin/mail or sendmail or whatever.

    --
    Mail me as org.uk _O_
    |<

    Richard Guest

Similar Threads

  1. Like CFPOP, but read text file of mail message and p instead
    By Charles R. Thompson in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: July 23rd, 04:50 AM
  2. Attach file to PHP-generated mail-message
    By Jan Bos in forum PHP Development
    Replies: 1
    Last Post: January 15th, 09:36 AM
  3. [PHP] mail() - how to attach file to the message???
    By Szparag in forum PHP Development
    Replies: 0
    Last Post: July 10th, 08:22 AM
  4. mail() - how to attach file to the message???
    By Sven in forum PHP Development
    Replies: 0
    Last Post: July 9th, 11:46 AM
  5. [PHP] mail() - how to attach file to the message???
    By Marek Kilimajer in forum PHP Programming
    Replies: 1
    Last Post: July 9th, 11:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139