Forwarding emails to kindle

2012-04-17 Thread SK
Hi all,

I am trying to get a workflow setup as follows:

Need: I would like to read articles / long emails distributed in
mailing lists via kindle

step 1: browse though emails in mutt in laptop
step 2: forward some interesting emails to x...@free.kindle.com address
step 3: download the emails as "Personal Documents" in kindle
step 4: go offline and read them in kindle

I am having issue with step 2 because every email I forward to
Amazon/kindle comes back with the error:

--error msg--
Your message to x...@free.kindle.com, sent at xxx GMT did not include
any attached documents or image files.

The Kindle Personal Document Service can convert and deliver the
following types of documents:
Microsoft Word (.doc, .docx)
Rich Text Format (.rtf)
HTML (.htm, .html)
Text (.txt) documents
Archived documents (zip , x-zip) and compressed archived documents
Mobi book

Images that are of type JPEGs (.jpg), GIFs (.gif), Bitmaps (.bmp), and
PNG images (.png).
Adobe PDF (.pdf) documents are delivered without conversion to Kindle
DX, Second Generation and Latest Generation Kindles.

Conversion of Adobe PDF (.pdf) to Kindle format is done on experimental basis.

If the document(s) that failed belonged to one of the above document
types, please ensure the document is not password protected or
encrypted. Note that the Latest Generation Kindles support password
protected PDFs.
--/error msg--

I did forward the email as attachment but for some reason I guess
amazon is not really interpreting the attaching as one of the valid
types.

Has anyone done anything similar or know what could be going wrong?

Thanks,
skn


Re: Forwarding emails to kindle

2012-04-17 Thread Toby Cubitt
On Tue, Apr 17, 2012 at 10:46:59AM +0200, SK wrote:
> I am having issue with step 2 because every email I forward to
> Amazon/kindle comes back with the error:
> 
> --error msg--
> Your message to x...@free.kindle.com, sent at xxx GMT did not include
> any attached documents or image files.
> 
> The Kindle Personal Document Service can convert and deliver the
> following types of documents:
> Microsoft Word (.doc, .docx)
> Rich Text Format (.rtf)
> HTML (.htm, .html)
> Text (.txt) documents
> Archived documents (zip , x-zip) and compressed archived documents
> Mobi book
> 
> I did forward the email as attachment but for some reason I guess
> amazon is not really interpreting the attaching as one of the valid
> types.

Not owning a Kindle, this is complete speculation. But at a guess Amazon
is recognising text documents either by their mime type, or (ugh!) by the
.txt filename extension.

In case you haven't already tried this, you can manually change the mime
type of the attachment from the compose menu using  (bound to
^T by default), and set it to "text/plain".

Failing that, saving the mail you want to forward to a file with
extension .txt, then attaching that file to a new mail, will both produce
the desired file extension and automatically set the mime type to
"text/plain" (assuming you have mime.types configured sanely).

HTH,

Toby
-- 
Dr T. S. Cubitt
Mathematics and Quantum Information group
Department of Mathematics
Complutense University
Madrid, Spain

email: ts...@cantab.net
web:   www.dr-qubit.org


Re: Forwarding emails to kindle

2012-04-17 Thread SK
>> I am having issue with step 2 because every email I forward to
>> Amazon/kindle comes back with the error:
>>
>> --error msg--
>> Your message to x...@free.kindle.com, sent at xxx GMT did not include
>> any attached documents or image files.
>>
>> The Kindle Personal Document Service can convert and deliver the
>> following types of documents:
>> Microsoft Word (.doc, .docx)
>> Rich Text Format (.rtf)
>> HTML (.htm, .html)
>> Text (.txt) documents
>> Archived documents (zip , x-zip) and compressed archived documents
>> Mobi book
>>
>> I did forward the email as attachment but for some reason I guess
>> amazon is not really interpreting the attaching as one of the valid
>> types.
>
> Not owning a Kindle, this is complete speculation. But at a guess Amazon
> is recognising text documents either by their mime type, or (ugh!) by the
> .txt filename extension.
>
> In case you haven't already tried this, you can manually change the mime
> type of the attachment from the compose menu using  (bound to
> ^T by default), and set it to "text/plain"

That does not work for two reasons:

- amazon does not recognise the forwarded attachment as "attachment"
for some reason
- when I covert from message/rfc822 to text/plain, the whole msg
header part gets dumped in.

> Failing that, saving the mail you want to forward to a file with
> extension .txt, then attaching that file to a new mail, will both produce
> the desired file extension and automatically set the mime type to
> "text/plain" (assuming you have mime.types configured sanely).

That works indeed. However it is a painful manual process. Any quick
way to automate it?

Thanks,
skn

>
> HTH,
>
> Toby
> --
> Dr T. S. Cubitt
> Mathematics and Quantum Information group
> Department of Mathematics
> Complutense University
> Madrid, Spain
>
> email: ts...@cantab.net
> web:   www.dr-qubit.org


Re: Forwarding emails to kindle

2012-04-17 Thread Dennis Guhl
On Tue, Apr 17, 2012 at 02:29:26PM +0200, SK wrote:
> Toby Cubitt wrote:

[..]

> > In case you haven't already tried this, you can manually change the mime
> > type of the attachment from the compose menu using  (bound to
> > ^T by default), and set it to "text/plain"
> 
> That does not work for two reasons:
> 
> - amazon does not recognise the forwarded attachment as "attachment"
> for some reason

If you forward the email as an attachment (look for mime_forward in
the manual) you can prevent this.

> - when I covert from message/rfc822 to text/plain, the whole msg
> header part gets dumped in.

To prevent this you would have to cut out the headers, which would be
difficult with simple forwarding.

> > Failing that, saving the mail you want to forward to a file with
> > extension .txt, then attaching that file to a new mail, will both produce
> > the desired file extension and automatically set the mime type to
> > "text/plain" (assuming you have mime.types configured sanely).
> 
> That works indeed. However it is a painful manual process. Any quick
> way to automate it?

Write a macro saving the message to a txt and composing a new email
with the file attached. But be aware, this file will also contain the
full headers. You would probably need a script to cut out the headers.

Dennis


Re: Forwarding emails to kindle

2012-04-17 Thread SK
>> > In case you haven't already tried this, you can manually change the mime
>> > type of the attachment from the compose menu using  (bound to
>> > ^T by default), and set it to "text/plain"
>>
>> That does not work for two reasons:
>>
>> - amazon does not recognise the forwarded attachment as "attachment"
>> for some reason
>
> If you forward the email as an attachment (look for mime_forward in
> the manual) you can prevent this.

Strangely enough even when I forward as attachment (text/plain), the
amazon system does not recognise it as an attachment.

I am not sure why.

>> - when I covert from message/rfc822 to text/plain, the whole msg
>> header part gets dumped in.
>
> To prevent this you would have to cut out the headers, which would be
> difficult with simple forwarding.
>
>> > Failing that, saving the mail you want to forward to a file with
>> > extension .txt, then attaching that file to a new mail, will both produce
>> > the desired file extension and automatically set the mime type to
>> > "text/plain" (assuming you have mime.types configured sanely).
>>
>> That works indeed. However it is a painful manual process. Any quick
>> way to automate it?
>
> Write a macro saving the message to a txt and composing a new email
> with the file attached. But be aware, this file will also contain the
> full headers. You would probably need a script to cut out the headers.

That seems to be the way out since I can also convert the text/plain
to mobi or whatever that amazon overlords want. Can you help by
providing a skeleton of a macro? I can try to hook it to a a
perl/python script that removes headers and convert to .mobi etc.

Thanks,
skn


Re: Forwarding emails to kindle

2012-04-17 Thread Leo Vegoda
Hi,

On Tue, Apr 17, 2012 at 1:46 AM, SK  wrote:

[...]

> Need: I would like to read articles / long emails distributed in
> mailing lists via kindle
>
> step 1: browse though emails in mutt in laptop
> step 2: forward some interesting emails to x...@free.kindle.com address
> step 3: download the emails as "Personal Documents" in kindle
> step 4: go offline and read them in kindle
>
> I am having issue with step 2 because every email I forward to
> Amazon/kindle comes back with the error:

For articles that appear in web pages I suggest using a service like
Instapaper. It will save them for you and automatically send you an
email to your u...@free.kindle.com address every morning with the most
recent 20 articles. It works a treat.

If you have a Kindle Fire you might want to look at the apps that
interface with Instapaper instead. There are some good ones.

Regards,

Leo


Re: Forwarding emails to kindle

2012-04-17 Thread David Champion
Offhand, the most straightforward way I can think of to do this
without including headers is to use a command designed to filter those
appropriately.  Roughly, I'd look at using a macro that pipes to such a
command and then feeds it to another mutt instance to send to Amazon.
Something like:

macro index =k 'enscript -G2r -Email -p- | pstopdf 
>/tmp/mail.pdf; mutt -s email -a /tmp/mail.pdf -- m...@free.kindle.com 
' 'Send as PDF to Kindle'

I haven't tested that, but since I have a Kindle I can work on it if you
have trouble.

There are endless variations if you want text vs pdf, etc, but this
basic formula should work.

-- 
David Champion • d...@uchicago.edu • IT Services • University of Chicago


Re: Forwarding emails to kindle

2012-04-17 Thread SK
> For articles that appear in web pages I suggest using a service like
> Instapaper. It will save them for you and automatically send you an
> email to your u...@free.kindle.com address every morning with the most
> recent 20 articles. It works a treat.

Already have a good workflow for articles and rss feeds:

articles: kindler (https://github.com/skn/kindler)  since I don't like
to bundle all the articles (as instapaper does)
rss feeds: newsbeuter ->pinboard -> kindler

Thanks,
skn


mutt and stdin

2012-04-17 Thread Andrei Mikhailov
Dear Mutt Users,

I am not sure if this is a bug of mutt, or my poor knowledge of Linux.
I would expect that this command:

  echo mymaildir | xargs mutt -f 

be equivalent to:

  mutt -f mymaildir

But instead, mutt complains about ``no recipient specified''.
Please help me to figure this out!

Andrei

PS: sorry I tried to ask this question on IRC yesterday, but I dont
know how to use IRC. I think I did something wrong and missed
the answer. I apologize for asking again here.


Re: mutt and stdin

2012-04-17 Thread Derek Martin
On Tue, Apr 17, 2012 at 11:46:15AM -0300, Andrei Mikhailov wrote:
> I would expect that this command:
> 
>   echo mymaildir | xargs mutt -f 
> 
> be equivalent to:
> 
>   mutt -f mymaildir
> 
> But instead, mutt complains about ``no recipient specified''.
> Please help me to figure this out!

The problem here is that when you run it this way, Mutt's stdin is not
a terminal.  When that's the case, mutt expects you're composing a
message on the command line, and will complain when you don't provide
it enough options to specify the message envelope:

$ mutt -f Mailbox < /dev/null
No recipients were specified.

For the UI to work, stdin must be a terminal, so that mutt (or rather,
whichever terminal control library it uses) knows what to send to the
terminal to draw the screen, etc.  AFAIK there's no way around that.

-- 
Derek D. Martinhttp://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.



pgplNobGrQzAV.pgp
Description: PGP signature


Re: mutt and stdin

2012-04-17 Thread Andrei Mikhailov
Thank you !
I think I now understand, more or less, why it does not work as expected.
Perhaps my question is more about Linux, than about Mutt. What I really
want to achieve is the following:

  echo "mydata" | myscript.sh

where myscript.sh is the following:

  #!/bin/bash
  some-program-which-reads-from-stdin.sh
  mutt

In other words, the script first reads the pipe and does something, 
and then just calls mutt.
Somehow, beteween ``some-program-...'' and ``mutt'' I have to insert
some command, saying:
  ``finished reading pipe, control is now returning to the terminal''
Is that possible?
Is it possible to call Mutt from within scripts accepting pipe input?

On Tue, Apr 17, 2012 at 10:37:55AM -0500, Derek Martin wrote:
> On Tue, Apr 17, 2012 at 11:46:15AM -0300, Andrei Mikhailov wrote:
> > I would expect that this command:
> > 
> >   echo mymaildir | xargs mutt -f 
> > 
> > be equivalent to:
> > 
> >   mutt -f mymaildir
> > 
> > But instead, mutt complains about ``no recipient specified''.
> > Please help me to figure this out!
> 
> The problem here is that when you run it this way, Mutt's stdin is not
> a terminal.  When that's the case, mutt expects you're composing a
> message on the command line, and will complain when you don't provide
> it enough options to specify the message envelope:
> 
> $ mutt -f Mailbox < /dev/null
> No recipients were specified.
> 
> For the UI to work, stdin must be a terminal, so that mutt (or rather,
> whichever terminal control library it uses) knows what to send to the
> terminal to draw the screen, etc.  AFAIK there's no way around that.
> 
> -- 
> Derek D. Martinhttp://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
> -=-=-=-=-
> This message is posted from an invalid address.  Replying to it will result in
> undeliverable mail due to spam prevention.  Sorry for the inconvenience.
> 




Re: mutt and stdin

2012-04-17 Thread Luis Mochan
On Tue, Apr 17, 2012 at 01:10:43PM -0300, Andrei Mikhailov wrote:
> Thank you !
> I think I now understand, more or less, why it does not work as expected.
> Perhaps my question is more about Linux, than about Mutt. What I really
> want to achieve is the following:
> 
>   echo "mydata" | myscript.sh
> 
> where myscript.sh is the following:
> 
>   #!/bin/bash
>   some-program-which-reads-from-stdin.sh
>   mutt
If your purpose is automatically sending mail based on 'mydata' and
the results of some-program..., maybe you shouldn't use mutt, which I
believe is designed for interactive use. For example, in my perl
scripts I use Mime::Lite to send email as

my $msg=MIME::Lite->new(
From=>'My Name ',
To=>'Her name ',
Subject=>"My subject",
Type=>'text/plain; charset=utf-8',
Data=>"The message text with interpolated $variables",
);
$msg->attach(
Type=>'text/plain;charset=utf8',
Path=>'aTextFile.txt',
Disposition=>'inline'
);
$msg->attach(
Type=>'image/jpg',
Path=>'anImageFile.jpg',
Disposition=>'attachment'
);
   $msg->send;

Best regards,
Luis

> 
> In other words, the script first reads the pipe and does something, 
> and then just calls mutt.
> Somehow, beteween ``some-program-...'' and ``mutt'' I have to insert
> some command, saying:
>   ``finished reading pipe, control is now returning to the terminal''
> Is that possible?
> Is it possible to call Mutt from within scripts accepting pipe input?
> 
> On Tue, Apr 17, 2012 at 10:37:55AM -0500, Derek Martin wrote:
> > On Tue, Apr 17, 2012 at 11:46:15AM -0300, Andrei Mikhailov wrote:
> > > I would expect that this command:
> > > 
> > >   echo mymaildir | xargs mutt -f 
> > > 
> > > be equivalent to:
> > > 
> > >   mutt -f mymaildir
> > > 
> > > But instead, mutt complains about ``no recipient specified''.
> > > Please help me to figure this out!
> > 
> > The problem here is that when you run it this way, Mutt's stdin is not
> > a terminal.  When that's the case, mutt expects you're composing a
> > message on the command line, and will complain when you don't provide
> > it enough options to specify the message envelope:
> > 
> > $ mutt -f Mailbox < /dev/null
> > No recipients were specified.
> > 
> > For the UI to work, stdin must be a terminal, so that mutt (or rather,
> > whichever terminal control library it uses) knows what to send to the
> > terminal to draw the screen, etc.  AFAIK there's no way around that.
> > 
> > -- 
> > Derek D. Martinhttp://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
> > -=-=-=-=-
> > This message is posted from an invalid address.  Replying to it will result 
> > in
> > undeliverable mail due to spam prevention.  Sorry for the inconvenience.
> > 
> 
> 

-- 

  o
W. Luis Mochán,  | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
Apdo. Postal 48-3, 62251 |   (*)/\/  \
Cuernavaca, Morelos, México  | moc...@fis.unam.mx   /\_/\__/

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org 




Re: mutt and stdin

2012-04-17 Thread Gary Johnson
On 2012-04-17, Andrei Mikhailov wrote:
> Thank you !
> I think I now understand, more or less, why it does not work as expected.
> Perhaps my question is more about Linux, than about Mutt. What I really
> want to achieve is the following:
> 
>   echo "mydata" | myscript.sh
> 
> where myscript.sh is the following:
> 
>   #!/bin/bash
>   some-program-which-reads-from-stdin.sh
>   mutt
> 
> In other words, the script first reads the pipe and does something, 
> and then just calls mutt.
> Somehow, beteween ``some-program-...'' and ``mutt'' I have to insert
> some command, saying:
>   ``finished reading pipe, control is now returning to the terminal''
> Is that possible?
> Is it possible to call Mutt from within scripts accepting pipe input?

Yes.  You just need to connect mutt's stdin to a terminal, e.g.,

#!/bin/bash
do-something-with-data-read-from-stdin
< /dev/tty mutt your-mutt-options

Regards,
Gary



Re: mutt and stdin

2012-04-17 Thread David Champion
* On 17 Apr 2012, Derek Martin wrote: 
> On Tue, Apr 17, 2012 at 11:46:15AM -0300, Andrei Mikhailov wrote:
> > I would expect that this command:
> > 
> >   echo mymaildir | xargs mutt -f 
> > 
> > be equivalent to:
> > 
> >   mutt -f mymaildir
> > 
> > But instead, mutt complains about ``no recipient specified''.
> > Please help me to figure this out!
> 
> The problem here is that when you run it this way, Mutt's stdin is not
> a terminal.  When that's the case, mutt expects you're composing a
> message on the command line, and will complain when you don't provide
> it enough options to specify the message envelope:
> 
> $ mutt -f Mailbox < /dev/null
> No recipients were specified.
> 
> For the UI to work, stdin must be a terminal, so that mutt (or rather,
> whichever terminal control library it uses) knows what to send to the
> terminal to draw the screen, etc.  AFAIK there's no way around that.

TTY=$(tty); echo mymaildir | xargs -I{} sh -c "mutt -f '{}' <$TTY"

-- 
David Champion • d...@uchicago.edu • IT Services • University of Chicago


pgpAVfAbUUNu0.pgp
Description: PGP signature


Re: mutt and stdin

2012-04-17 Thread Brian Cuttler

I'd thought he could put the data into a file and then
invoke mutt, something like.



mutt -s $subject_string $delivery_to_string < message_file

At least this works for me when using mailx, but that is a
very different utility than mutt.



On Tue, Apr 17, 2012 at 11:24:10AM -0500, Luis Mochan wrote:
> On Tue, Apr 17, 2012 at 01:10:43PM -0300, Andrei Mikhailov wrote:
> > Thank you !
> > I think I now understand, more or less, why it does not work as expected.
> > Perhaps my question is more about Linux, than about Mutt. What I really
> > want to achieve is the following:
> > 
> >   echo "mydata" | myscript.sh
> > 
> > where myscript.sh is the following:
> > 
> >   #!/bin/bash
> >   some-program-which-reads-from-stdin.sh
> >   mutt
> If your purpose is automatically sending mail based on 'mydata' and
> the results of some-program..., maybe you shouldn't use mutt, which I
> believe is designed for interactive use. For example, in my perl
> scripts I use Mime::Lite to send email as
> 
> my $msg=MIME::Lite->new(
>   From=>'My Name ',
>   To=>'Her name ',
>   Subject=>"My subject",
>   Type=>'text/plain; charset=utf-8',
>   Data=>"The message text with interpolated $variables",
> );
> $msg->attach(
>   Type=>'text/plain;charset=utf8',
>   Path=>'aTextFile.txt',
>   Disposition=>'inline'
>   );
> $msg->attach(
>   Type=>'image/jpg',
>   Path=>'anImageFile.jpg',
>   Disposition=>'attachment'
>   );
>$msg->send;
> 
> Best regards,
> Luis
> 
> > 
> > In other words, the script first reads the pipe and does something, 
> > and then just calls mutt.
> > Somehow, beteween ``some-program-...'' and ``mutt'' I have to insert
> > some command, saying:
> >   ``finished reading pipe, control is now returning to the terminal''
> > Is that possible?
> > Is it possible to call Mutt from within scripts accepting pipe input?
> > 
> > On Tue, Apr 17, 2012 at 10:37:55AM -0500, Derek Martin wrote:
> > > On Tue, Apr 17, 2012 at 11:46:15AM -0300, Andrei Mikhailov wrote:
> > > > I would expect that this command:
> > > > 
> > > >   echo mymaildir | xargs mutt -f 
> > > > 
> > > > be equivalent to:
> > > > 
> > > >   mutt -f mymaildir
> > > > 
> > > > But instead, mutt complains about ``no recipient specified''.
> > > > Please help me to figure this out!
> > > 
> > > The problem here is that when you run it this way, Mutt's stdin is not
> > > a terminal.  When that's the case, mutt expects you're composing a
> > > message on the command line, and will complain when you don't provide
> > > it enough options to specify the message envelope:
> > > 
> > > $ mutt -f Mailbox < /dev/null
> > > No recipients were specified.
> > > 
> > > For the UI to work, stdin must be a terminal, so that mutt (or rather,
> > > whichever terminal control library it uses) knows what to send to the
> > > terminal to draw the screen, etc.  AFAIK there's no way around that.
> > > 
> > > -- 
> > > Derek D. Martinhttp://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
> > > -=-=-=-=-
> > > This message is posted from an invalid address.  Replying to it will 
> > > result in
> > > undeliverable mail due to spam prevention.  Sorry for the inconvenience.
> > > 
> > 
> > 
> 
> -- 
> 
>   o
> W. Luis Moch?n,  | tel:(52)(777)329-1734 /<(*)
> Instituto de Ciencias F?sicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
> Apdo. Postal 48-3, 62251 |   (*)/\/  \
> Cuernavaca, Morelos, M?xico  | moc...@fis.unam.mx   /\_/\__/
> 
> O< ascii ribbon campaign - stop html mail - www.asciiribbon.org   
>   
> 
> 
---
   Brian R Cuttler brian.cutt...@wadsworth.org
   Computer Systems Support(v) 518 486-1697
   Wadsworth Center(f) 518 473-6384
   NYS Department of HealthHelp Desk 518 473-0773



IMPORTANT NOTICE: This e-mail and any attachments may contain
confidential or sensitive information which is, or may be, legally
privileged or otherwise protected by law from further disclosure.  It
is intended only for the addressee.  If you received this in error or
from someone who was not authorized to send it to you, please do not
distribute, copy or use it or any attachments.  Please notify the
sender immediately by reply e-mail and delete this from your
system. Thank you for your cooperation.




Re: mutt and stdin

2012-04-17 Thread Andrei Mikhailov
Thank you, this solved my problem.
I knew it was a Linux question.

> TTY=$(tty); echo mymaildir | xargs -I{} sh -c "mutt -f '{}' <$TTY"
> 
> -- 
> David Champion • d...@uchicago.edu • IT Services • University of Chicago




Re: mutt and stdin

2012-04-17 Thread Derek Martin
On Tue, Apr 17, 2012 at 11:36:04AM -0500, David Champion wrote:
> TTY=$(tty); echo mymaildir | xargs -I{} sh -c "mutt -f '{}' <$TTY"

Nice!  I wasn't familiar with that usage of xargs...

-- 
Derek D. Martinhttp://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.



pgpSOEH6fZN1Z.pgp
Description: PGP signature


Re: mutt and stdin

2012-04-17 Thread David Champion
* On 17 Apr 2012, Derek Martin wrote: 
> On Tue, Apr 17, 2012 at 11:36:04AM -0500, David Champion wrote:
> > TTY=$(tty); echo mymaildir | xargs -I{} sh -c "mutt -f '{}' <$TTY"
> 
> Nice!  I wasn't familiar with that usage of xargs...

It even appears to be fairly portable.  BSD xargs also has -o, which
does all the tty redirection for you.

echo mailmaildir | xargs -o mutt -f

Actually using /dev/tty should be adequate, instead of worrying about
$(tty):

echo mymaildir | xargs -I{} sh -c "mutt -f '{}' 

pgptpomhrolof.pgp
Description: PGP signature


Re: mutt and stdin

2012-04-17 Thread Grant Edwards
On 2012-04-17, Luis Mochan  wrote:
> On Tue, Apr 17, 2012 at 01:10:43PM -0300, Andrei Mikhailov wrote:
>> Thank you !
>> I think I now understand, more or less, why it does not work as expected.
>> Perhaps my question is more about Linux, than about Mutt. What I really
>> want to achieve is the following:
>> 
>>   echo "mydata" | myscript.sh
>> 
>> where myscript.sh is the following:
>> 
>>   #!/bin/bash
>>   some-program-which-reads-from-stdin.sh
>>   mutt

> If your purpose is automatically sending mail based on 'mydata' and
> the results of some-program..., maybe you shouldn't use mutt, which I
> believe is designed for interactive use.

It works fine for some cases sending mail non-interactive:

 echo "this is the message body" | mutt -s "subject here" 
username@whatever.invalid

If you want to attache file or two, just add some "-a" options.

-- 
Grant Edwards   grant.b.edwardsYow! Mary Tyler Moore's
  at   SEVENTH HUSBAND is wearing
  gmail.commy DACRON TANK TOP in a
   cheap hotel in HONOLULU!



Re: Forwarding emails to kindle

2012-04-17 Thread SK
On Tue, Apr 17, 2012 at 3:58 PM, David Champion  wrote:
> Offhand, the most straightforward way I can think of to do this
> without including headers is to use a command designed to filter those
> appropriately.  Roughly, I'd look at using a macro that pipes to such a
> command and then feeds it to another mutt instance to send to Amazon.
> Something like:
>
> macro index =k 'enscript -G2r -Email -p- | pstopdf 
> >/tmp/mail.pdf; mutt -s email -a /tmp/mail.pdf -- m...@free.kindle.com 
> ' 'Send as PDF to Kindle'
>
> I haven't tested that, but since I have a Kindle I can work on it if you
> have trouble.
>
> There are endless variations if you want text vs pdf, etc, but this
> basic formula should work.

Thanks! I settled on a variation of this for now though, as you said,
I can keep playing with this for some time to get the best result:

macro index,pager \ck
'~/.mutt/scripts/strip-email-headers.pl| enscript -f
"Times-Roman10" -B -p - | ps2pdf - /tmp/email.pdf; mutt -s convert -a
/tmp/email.pdf -- a...@free.kindle.com ' 'Send as PDF to Kindle'



% cat ~/.mutt/scripts/strip-email-headers.pl

!/usr/bin/perl -w
#
#

while(<>)
{
last if ( /^\s*$/ );
}

print <>;