Date: Mon, 4 Apr 2005 12:21:55 -0400 (EDT) From: "Ean Kingston" <ean@hedron.org> To: freebsd-questions@freebsd.org Subject: Re: *attaching* a file to /usr/bin/mail message Message-ID: <3791.216.220.59.169.1112631715.squirrel@216.220.59.169> In-Reply-To: <20050402124754.GB6829@gothmog.gr> References: <20050402140601.D9329@kenmore.kozy-kabin.nl> <20050402124754.GB6829@gothmog.gr>
next in thread | previous in thread | raw e-mail | index | archive | help
> On 2005-04-02 14:08, "Colin J. Raven" <colin@kenmore.kozy-kabin.nl> wrote: >> Does anyone happen to know how you would *attach* *not readin the >> contents of, but actually *attach*) a file using /usr/bin/mail? > > 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". 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"<root@example.com> To: "test user"<test@example.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" begin 644 sample.txt M5&AI<R!I<R!A('-A;7!L92!F:6QE('1H870@=VEL;"!B92!U=65N8V]D960@ M=&\@8F4@9&5L:79E<F5D(&%S(&%N(&4M;6%I; IA='1A8VAM96YT+B!)="!I M<RP@;V)V:6]U<VQY(&$@=&5X="!F:6QE+@H*5&AI<R!S:&]U;&0@8F4@=&AE .(&9O=7)T:"!L:6YE+@H@ end --This_can_not_match_any_other_line_in_the_message-- You use it like this: /usr/bin/mail test@example.com < mail_with_attachment.txt Obviously, you will have to uuencode your own attachment and replace the one from the example. > >> 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.... > > 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 recipient.address@example.net > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" > -- Ean Kingston E-Mail: ean_AT_hedron_DOT_org PGP KeyID: 1024D/CBC5D6BB URL: http://www.hedron.org/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3791.216.220.59.169.1112631715.squirrel>