How mutt check to download emails from an imap server without downloading them more than once?

2023-03-19 Thread Peng Yu
Hi,

I use the following python code to download UNDELETED messages. But it
will fetch all messages without considering whether an message has
been downloaded previously. How does mutt solve this problem to only
download the emails that have not been downloaded before.

import email
with IMAPClient(host=host) as client:
  client.login(user, passwd)
  client.select_folder('INBOX', readonly=True) # preserve the \Recent flag.
  messages = client.search(search_criteria) # UNDELETED
  response = client.fetch(messages, ['RFC822'])
  for message_id, data in response.items():
with open('%s/%d.eml' % (outdir, message_id), 'wb') as f:
  f.write(data[b'RFC822'])

-- 
Regards,
Peng


Re: How does mutt know to automatically choose charset?

2021-02-12 Thread Peng Yu
On 2/12/21, Derek Martin  wrote:
> On Thu, Feb 04, 2021 at 08:42:31AM -0600, Peng Yu wrote:
>> mutt can adjust the charset based on the input. But it seems that
>> EmailMessage from python can not do this automatically. How does mutt
>> choose the charset automatically based on the content? Thanks.
>
> You pasted the answer:
>> Content-Type: text/plain; charset=us-ascii
> ...
>> Content-Type: text/plain; charset=utf-8

The above are just the output of mutt. My question is how mutt knows
what charset to use. By what function mutt scans the input to
determine the charset?

-- 
Regards,
Peng


Re: How to generate html mime message?

2021-02-07 Thread Peng Yu
I just want to generate the HTML mine message. The instruction
requires the set up of mutt, which I want to avoid. Is
`bin/plain2html` for generating HTML mime message from a plain text?
Can you make the plain2html module installable so that the following
command will work? Thanks.

$ bin/plain2html
Traceback (most recent call last):
  File "bin/plain2html", line 36, in 
from plain2html import settings
ModuleNotFoundError: No module named 'plain2html'


On 2/7/21, Amit Ramon  wrote:
> Hello Peng,
>
> While this might not be the answer for how to use pandoc, it is an answer
> to the question in the subject, so I hope it's right.
>
> I'm the author of https://github.com/amitramon/plainMail2HTML - this
> is a simple tool that allows for generating HTML mime part from any
> email sent from Mutt. Perhaps you'll find it useful.
>
> Cheers,
>
> Amit
>
> Peng Yu  [2021-02-07 09:26 -0600]:
>
>>Hi,
>>
>>https://unix.stackexchange.com/questions/108485/send-email-written-in-markdown-using-mutt
>>
>>I see the following muttrc command is used to compose an HTML message
>>on the above URL. I just want to inspect the mime message in the
>>command line without using the GUI.
>>
>>macro compose \e5 "F pandoc -s -f markdown -t html \ny^T^Utext/html;
>>charset=utf-8\n"
>>set wait_key=no
>>
>>Could anybody let me know how to create the mime message using mutt
>>given an html file already generated by pandoc from markdown?
>>
>>I understand "html; charset=utf-8" is to set the following Content-Type.
>>
>>Content-Type: text/html; charset=UTF-8
>>
>>But what does "y^T^U" do?
>>
>>--
>>Regards,
>>Peng
>
> --
>


-- 
Regards,
Peng


How to generate html mime message?

2021-02-07 Thread Peng Yu
Hi,

https://unix.stackexchange.com/questions/108485/send-email-written-in-markdown-using-mutt

I see the following muttrc command is used to compose an HTML message
on the above URL. I just want to inspect the mime message in the
command line without using the GUI.

macro compose \e5 "F pandoc -s -f markdown -t html \ny^T^Utext/html;
charset=utf-8\n"
set wait_key=no

Could anybody let me know how to create the mime message using mutt
given an html file already generated by pandoc from markdown?

I understand "html; charset=utf-8" is to set the following Content-Type.

Content-Type: text/html; charset=UTF-8

But what does "y^T^U" do?

-- 
Regards,
Peng


How to remove `To: undisclosed-recipients: ;`?

2021-02-04 Thread Peng Yu
Hi,

I want to remove `To: undisclosed-recipients: ;` in the generated
message when no To or Cc recipients are specified. I don't see an
option to do this in the manual. Could anybody let me know if there is
an option to remove it? Thanks.

http://www.mutt.org/doc/manual/

-- 
Regards,
Peng


How to show bcc in the raw message generate by mutt?

2021-02-04 Thread Peng Yu
Hi,

The Bcc field is not shown in the generated message. Is there a way to
let mutt generate the Bcc field from the command line? Thanks.

$ mutt -F temp.muttrc -b b...@addr.com -c c...@addr.com t...@addr.com <<< aaa
Date: Thu, 4 Feb 2021 10:21:10 -0600
From: My name 
To: t...@addr.com
Cc: c...@addr.com
Message-ID: <20210204162110.ga98...@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

aaa
$ cat temp.muttrc
set realname='My name'
set from=mya...@gmail.com
set hostname = gmail.com
set sendmail=/tmp/mycat.sh
$ cat /tmp/mycat.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

cat

-- 
Regards,
Peng


How does mutt know to automatically choose charset?

2021-02-04 Thread Peng Yu
Hi,

mutt can adjust the charset based on the input. But it seems that
EmailMessage from python can not do this automatically. How does mutt
choose the charset automatically based on the content? Thanks.

https://docs.python.org/3/library/email.message.html

$ mutt -F temp.muttrc t...@addr.com <<< a
Date: Thu, 4 Feb 2021 08:35:21 -0600
From: My name 
To: t...@addr.com
Message-ID: <20210204143521.ga84...@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

a
$ mutt -F temp.muttrc t...@addr.com <<< α
Date: Thu, 4 Feb 2021 08:31:35 -0600
From: My name 
To: t...@addr.com
Message-ID: <20210204143135.ga84...@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

α
$ cat temp.muttrc
set realname='My name'
set from=mya...@gmail.com
set hostname = gmail.com
set sendmail=/tmp/mycat.sh
$ cat /tmp/mycat.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

cat

-- 
Regards,
Peng


Re: not to set message id in outgoing email

2021-02-03 Thread Peng Yu
On Wed, Feb 3, 2021 at 11:23 AM Will Yardley
 wrote:
>
> On Wed, Feb 03, 2021 at 08:57:32AM -0600, Peng Yu wrote:
> >
> > When I use mutt to construct an outgoing email, is there a way not to
> > set the message id? Thanks.
>
> Even if Mutt doesn't set one, the first MTA it hits will add one.

I want the first MTA add one, instead of using the one generated by mutt.

> Not
> setting one will also break threading. What exactly is your goal here?
> And, as others have said, is the goal for the resulting message someone
> receives to not have one (likely impossible), or just for Mutt to not
> set one?
>
> /w



--
Regards,
Peng


Re: not to set message id in outgoing email

2021-02-03 Thread Peng Yu
> I don't know if it's possible to remove the header altogether, but you
> can make mutt show only specific headers by using the "ignore" and
> "unignore" commands as specified in the mutt manual.
>
> In the sample starter muttrc file provided by the mutt package in my
> distribution, there are the following lines:
>
> ignore *
> unignore From Message-ID Date To Cc Bcc Subject

This does not work. Have you tried it yourself?

$ cat mycat.sh
#!/usr/bin/env bash
cat
$ cat temp.muttrc
set realname='My name'
set from=mya...@gmail.com
set hostname = gmail.com
set sendmail=/tmp/mycat.sh
ignore *
$ mutt -F temp.muttrc  t...@addr.com <<< abc
Date: Wed, 3 Feb 2021 10:42:55 -0600
From: My name 
To: t...@addr.com
Message-ID: <20210203164255.ga66...@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

abc

-- 
Regards,
Peng


not to set message id in outgoing email

2021-02-03 Thread Peng Yu
Hi,

When I use mutt to construct an outgoing email, is there a way not to
set the message id? Thanks.

-- 
Regards,
Peng


What environment variable affects the "charset" variable?

2019-07-08 Thread Peng Yu
Hi,

`mutt -D` prints 'charset="iso-8859-1"' when it runs in a
non-interactive bash session scheduled by crontab.

But the same command prints 'charset="utf-8"' when it runs in an
interactive bash session. I suspect that this is affected by an
environment variable.

Does anybody know why there is such a difference?

-- 
Regards,
Peng


Re: How not to encode the To: field?

2019-07-03 Thread Peng Yu
OK. I see the problem. Gmail encode it as =?UTF-8..., but mutt encode
it as =?utf-8...

Should it be in upper cases instead of lower cases? Is there a way to
let mutt encode using "UTF-8"? Thanks.

https://github.com/golang/go/issues/19430

On 7/3/19, Kevin J. McCarthy  wrote:
> On Wed, Jul 03, 2019 at 03:01:40PM -0500, Peng Yu wrote:
>>In this email that I am sending, the "To:" field of the original
>>message should have "François" as is. Do you know why?
>
> To: =?UTF-8?B?RnJhbsOnb2lz?= 
>
> Looks to me like Gmail correctly encoded the name.  Am I
> misunderstanding your question?
>
> --
> Kevin J. McCarthy
> GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
>


-- 
Regards,
Peng


Re: How not to encode the To: field?

2019-07-03 Thread Peng Yu
In this email that I am sending, the "To:" field of the original
message should have "François" as is. Do you know why?

On 7/3/19, Kevin J. McCarthy  wrote:
> On Wed, Jul 03, 2019 at 01:27:02PM -0500, Peng Yu wrote:
>>"François" in the "To:" filed will be encoded as
>>"=?utf-8?B?RnJhbsOnb2lz?=". Is there a way to just use "François"
>>without being encoded in the "To:" field? Thanks.
>
> The rfc2047 encoding is required for non-ascii characters in certain
> parts of the message header.  There is no config variable to disable
> (only) it.
>
> That said, unsetting $charset will turn off the encoding process.
> However, it will also break many many other things in mutt.
>
> --
> Kevin J. McCarthy
> GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
>


-- 
Regards,
Peng


How not to encode the To: field?

2019-07-03 Thread Peng Yu
Hi,

I have the following line in the mutt config file.

set send_charset="us-ascii:utf-8"

"François" in the "To:" filed will be encoded as
"=?utf-8?B?RnJhbsOnb2lz?=". Is there a way to just use "François"
without being encoded in the "To:" field? Thanks.

-- 
Regards,
Peng


How to not disable the showing of hostname in message-id?

2019-03-16 Thread Peng Yu
Hi,

I set `hidden-host` to yes. But the hostname still shows up.

http://www.mutt.org/doc/manual/#hidden-host

I don't want to use the following solution as it still shows the
hostname even it is fake.

https://bbs.archlinux.org/viewtopic.php?id=213306

Could anybody let me know if there is a way to disable the appearance
of hostname in message-id? Thanks.

--
Regards,
Peng


How to debug muttrc? (for signature)

2016-08-14 Thread Peng Yu
Hi, I have the following line in my muttrc. But no signature is
generated in the email (I only tested mutt on the command line).

set signature="~/.signature"

Does anybody know how to debug muttrc to understand why no signature
is included in the generated emails?

-- 
Regards,
Peng


Re: How to debug muttrc? (for signature)

2016-08-14 Thread Peng Yu
BTW, I use the follow command to send the email.

mutt -s 'my subject' pengyu...@gmail.com <<< my_body

On Sun, Aug 14, 2016 at 10:40 AM, Peng Yu <pengyu...@gmail.com> wrote:
> Hi, I have the following line in my muttrc. But no signature is
> generated in the email (I only tested mutt on the command line).
>
> set signature="~/.signature"
>
> Does anybody know how to debug muttrc to understand why no signature
> is included in the generated emails?
>
> --
> Regards,
> Peng



-- 
Regards,
Peng


[SPAM?] How to allow mutt to send from different accounts on the command line?

2016-08-11 Thread Peng Yu
Hi, I have msmtp set up on my computer. But I don't find how to
specify different accounts to send email from mutt command line. Does
anybody know how to do it? Thanks.

-- 
Regards,
Peng


How to just view the email constructed by mutt without sending it?

2016-04-20 Thread Peng Yu
Hi, I use the following command to send email with mutt. But
sometimes, I want to inspect the email body constructed by mutt. Is
there a way to do so? Thanks.

echo "This is the message body" | mutt -s "subject of message" --
a...@domain.com

-- 
Regards,
Peng


Re: mutt configuration problems for gmail

2015-03-26 Thread Peng Yu
On Thu, Mar 26, 2015 at 6:34 PM, Eduardo A. Bustamante López
dual...@gmail.com wrote:
 On Thu, Mar 26, 2015 at 05:59:06PM -0500, Peng Yu wrote:
 System: Darwin 13.4.0 (x86_64) [using ncurses 5.9]
 Compile options:
 -DOMAIN
 -DEBUG
 -HOMESPOOL  +USE_SETGID  +USE_DOTLOCK  +DL_STANDALONE
 +USE_FCNTL  -USE_FLOCK
 -USE_POP  +USE_IMAP  -USE_GSS  +USE_SSL  -USE_SASL
 +HAVE_REGCOMP  -USE_GNU_REGEX
 +HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  +HAVE_BKGDSET
 +HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM
 +HAVE_PGP  -BUFFY_SIZE -EXACT_ADDRESS  -SUN_ATTACHMENT
 +ENABLE_NLS  -LOCALES_HACK  +COMPRESSED  +HAVE_WC_FUNCS
 +HAVE_LANGINFO_CODESET  +HAVE_LANGINFO_YESEXPR
 +HAVE_ICONV  -ICONV_NONTRANS  +HAVE_GETSID  +HAVE_GETADDRINFO

 ~$ mutt
 Error in /Users/py/.muttrc, line 10: trash: unknown variable
 Error in /Users/py/.muttrc, line 11: any_label: unknown variable
 Error in /Users/py/.muttrc, line 14: header_cache: unknown variable
 Error in /Users/py/.muttrc, line 15: message_cachedir: unknown variable
 Error in /Users/py/.muttrc, line 19: smtp_url: unknown variable
 Error in /Users/py/.muttrc, line 20: smtp_pass: unknown variable
 Error in /Users/py/.muttrc, line 26:
 source: errors in /Users/py/.muttrc
 Press any key to continue...

 --
 Regards,
 Peng

 You need to compile hcache support (+USE_HCACHE), smtp support (+USE_SMTP), 
 and
 probably many others. This is my mutt from debian unstable:

I have now the following installed.

  mutt-devel @1.5.23_1+compress+gdbm+imap+smtp+ssl+trash+xlabel (active)

But I still see the following errors.

~$ mutt
Error in /Users/py/.muttrc, line 11: any_label: unknown variable
Error in /Users/py/.muttrc, line 14: header_cache: unknown variable
Error in /Users/py/.muttrc, line 26:
source: errors in /Users/py/.muttrc

mutt-devel has the variants. What else do I need to enable? Thanks.

   compress: Compressed folders
   date_conditional: Allow the format of dates in the index to vary
based on how recent the message is
 * requires deepif
   db4: Use Berkeley DB database
 * conflicts with gdbm qdbm tokyocabinet
   debug: Debugging support
   deepif: Allow nested if-else sequences in strings
   gdbm: Use GNU dbm database
 * conflicts with db4 qdbm tokyocabinet
   gnuregex: Use the GNU regular expression library
   gpgme: Enable GPGME crypto support
   headercache: Enable header caching (requires gdbm, qdbm, or tokyocabinet)
 * conflicts with db4
   idn: Internationalized Domain Name support
[+]imap: IMAP support
   nntp: NNTP support
 * conflicts with sidebar
[+]pop: POP support
   qdbm: Use QDBM database
 * conflicts with db4 gdbm tokyocabinet
   sasl: Simple Authentication and Security Layer support
   sidebar: Add a sidebar with a list of folders
 * conflicts with nntp
   smtp: Include internal SMTP relay support
   ssl: Secure Sockets Layer support
   tokyocabinet: Use Tokyo Cabinet database
 * conflicts with db4 gdbm qdbm
   trash: Add a Trash folder
   universal: Build for multiple architectures
   xlabel: Custom message-tagging - X-Label:


 Compile options:
 -DOMAIN
 +DEBUG
 -HOMESPOOL  +USE_SETGID  +USE_DOTLOCK  +DL_STANDALONE  +USE_FCNTL  -USE_FLOCK
 +USE_POP  +USE_IMAP  +USE_SMTP
 -USE_SSL_OPENSSL  +USE_SSL_GNUTLS  +USE_SASL  +USE_GSS  +HAVE_GETADDRINFO
 +HAVE_REGCOMP  -USE_GNU_REGEX
 +HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  +HAVE_BKGDSET
 +HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM
 +CRYPT_BACKEND_CLASSIC_PGP  +CRYPT_BACKEND_CLASSIC_SMIME  +CRYPT_BACKEND_GPGME
 -EXACT_ADDRESS  -SUN_ATTACHMENT
 +ENABLE_NLS  -LOCALES_HACK  +COMPRESSED  +HAVE_WC_FUNCS  
 +HAVE_LANGINFO_CODESET  +HAVE_LANGINFO_YESEXPR
 +HAVE_ICONV  -ICONV_NONTRANS  +HAVE_LIBIDN  +HAVE_GETSID  +USE_HCACHE
 -ISPELL
 SENDMAIL=/usr/sbin/sendmail
 MAILPATH=/var/mail
 PKGDATADIR=/usr/share/mutt
 SYSCONFDIR=/etc
 EXECSHELL=/bin/sh
 MIXMASTER=mixmaster

 --
 Eduardo Bustamante | https://dualbus.me/



-- 
Regards,
Peng


mutt configuration problems for gmail

2015-03-26 Thread Peng Yu
Hi,

I have the following mutt installed through MacPorts on a Mac OS X
10.9.5, and I followed the instructions on
https://blog.bartbania.com/raspberry_pi/consolify-your-gmail-with-mutt/
to configure mutt. But when I run mutt, I see the following errors.
Does anybody know what wrong is wrong? Do I need to compile mutt on my
own?

~$ mutt -v
Mutt 1.4.2.3i (2007-05-26)
Copyright (C) 1996-2002 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.

System: Darwin 13.4.0 (x86_64) [using ncurses 5.9]
Compile options:
-DOMAIN
-DEBUG
-HOMESPOOL  +USE_SETGID  +USE_DOTLOCK  +DL_STANDALONE
+USE_FCNTL  -USE_FLOCK
-USE_POP  +USE_IMAP  -USE_GSS  +USE_SSL  -USE_SASL
+HAVE_REGCOMP  -USE_GNU_REGEX
+HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  +HAVE_BKGDSET
+HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM
+HAVE_PGP  -BUFFY_SIZE -EXACT_ADDRESS  -SUN_ATTACHMENT
+ENABLE_NLS  -LOCALES_HACK  +COMPRESSED  +HAVE_WC_FUNCS
+HAVE_LANGINFO_CODESET  +HAVE_LANGINFO_YESEXPR
+HAVE_ICONV  -ICONV_NONTRANS  +HAVE_GETSID  +HAVE_GETADDRINFO
ISPELL=/opt/local/bin/ispell
SENDMAIL=/usr/sbin/sendmail
MAILPATH=/var/mail
PKGDATADIR=/opt/local/share/mutt
SYSCONFDIR=/opt/local/etc
EXECSHELL=/bin/sh
-MIXMASTER
To contact the developers, please mail to mutt-...@mutt.org.
To report a bug, please use the flea(1) utility.

patch-1.4.2.3.rr.compressed.1

~$ mutt
Error in /Users/py/.muttrc, line 10: trash: unknown variable
Error in /Users/py/.muttrc, line 11: any_label: unknown variable
Error in /Users/py/.muttrc, line 14: header_cache: unknown variable
Error in /Users/py/.muttrc, line 15: message_cachedir: unknown variable
Error in /Users/py/.muttrc, line 19: smtp_url: unknown variable
Error in /Users/py/.muttrc, line 20: smtp_pass: unknown variable
Error in /Users/py/.muttrc, line 26:
source: errors in /Users/py/.muttrc
Press any key to continue...

-- 
Regards,
Peng