AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / ubuntu / Perguntas / 1494293
Accepted
Nicholas Saunders
Nicholas Saunders
Asked: 2023-11-29 15:00:47 +0800 CST2023-11-29 15:00:47 +0800 CST 2023-11-29 15:00:47 +0800 CST

Como iterar o arquivo eml com mailutils?

  • 772

Como um diretório de .emlarquivos seria iterado?

nicholas@mordor:~$ 
nicholas@mordor:~$ mail -f foomail/foo.eml 
"/home/nicholas/foomail/foo.eml": 0 messages
nicholas@mordor:~$ 

Considerando que eu gostaria de ver uma lista para selecionar.

command-line
  • 1 1 respostas
  • 74 Views

1 respostas

  • Voted
  1. Best Answer
    Raffa
    2023-11-30T22:56:22+08:002023-11-30T22:56:22+08:00

    Você não pode, o formato EML não é um dos formatos de caixa de correio local suportados pelo GNU Mailutils ... Mas, aparentemente, o formato MBOX é.

    Felizmente, a conversão de EML para MBOX é fácil e é isso que você provavelmente deveria considerar.

    Para demonstrar isso, usei este exemplo de EML ... então,

    $ head *.eml
    ==> 1.eml <==
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    
    ==> 2.eml <==
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], mailma[email protected]
    Message-ID: <[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    
    ==> 3.eml <==
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <05c18622-f2ad-cb77-2ce9-a0bbfc[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    

    ... e tente lê-los com mailutils( Não funciona ):

    $ mail -V
    mail (GNU Mailutils) 3.16
    Copyright (C) 2007-2023 Free Software Foundation, inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
    $
    $ 
    $ mail --file *.eml
    mail: -f requires at most one command line argument
    $ 
    $ 
    $ mail --file 1.eml
    "/home/ubuntu/test/dir/1.eml": 0 messages
    

    ... Agora vamos converter essas 3 mensagens EML em um arquivo MBOX:

    $ for e in *.eml
      do
        date +"From - %a %b %d %H:%M:%S %Y" >> file.mbox
        cat "$e" >> file.mbox
        echo >> file.mbox
        done
    $ 
    $ 
    $ ls -lh
    total 20K
    -rw-rw-r-- 1 ubuntu ubuntu 2.5K Nov 30 17:48 1.eml
    -rw-rw-r-- 1 ubuntu ubuntu 2.5K Nov 30 17:48 2.eml
    -rw-rw-r-- 1 ubuntu ubuntu 2.5K Nov 30 17:48 3.eml
    -rw-rw-r-- 1 ubuntu ubuntu 7.6K Nov 30 17:49 file.mbox
    $ 
    $ 
    $ head file.mbox 
    From - Thu Nov 30 17:49:34 2023
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <[email protected]>
    

    ... e tente ler:

    $ mail --file file.mbox 
    "/home/ubuntu/test/dir/file.mbox": 3 messages 3 new
    >N   1 piro-test@clear-co Thu Nov 30 17:49  64/2549  test confirmation
     N   2 piro-test@clear-co Thu Nov 30 17:49  64/2549  test confirmation
     N   3 piro-test@clear-co Thu Nov 30 17:49  64/2549  test confirmation
    ? 
    FCC: imap://[email protected]/Sent
    X-Identity-Key: id1
    X-Account-Key: account1
    From: "[email protected]" <[email protected]>
    Subject: test confirmation
    To: [email protected], [email protected],
     [email protected], [email protected], [email protected],
     [email protected], [email protected], [email protected]
    Message-ID: <[email protected]>
    Date: Thu, 15 Aug 2019 14:54:37 +0900
    X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0;
     attachmentreminder=0; deliveryformat=4
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101
     Thunderbird/69.0
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
     boundary="------------26A45336F6C6196BD8BBA2A2"
    Content-Language: en-US
    
    This is a multi-part message in MIME format.
    --------------26A45336F6C6196BD8BBA2A2
    Content-Type: text/plain; charset=utf-8; format=flowed
    Content-Transfer-Encoding: 7bit
    ? q
    Held 3 messages in /home/ubuntu/test/dir/file.mbox
    

    ... e funciona.

    • 1

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Existe um comando para listar todos os usuários? Também para adicionar, excluir, modificar usuários, no terminal?

    • 9 respostas
  • Marko Smith

    Como excluir um diretório não vazio no Terminal?

    • 4 respostas
  • Marko Smith

    Como descompactar um arquivo zip do Terminal?

    • 9 respostas
  • Marko Smith

    Como instalo um arquivo .deb por meio da linha de comando?

    • 11 respostas
  • Marko Smith

    Como instalo um arquivo .tar.gz (ou .tar.bz2)?

    • 14 respostas
  • Marko Smith

    Como listar todos os pacotes instalados

    • 24 respostas
  • Martin Hope
    Flimm Como posso usar o docker sem sudo? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    led-Zepp Como faço para salvar a saída do terminal em um arquivo? 2014-02-15 11:49:07 +0800 CST
  • Martin Hope
    ubuntu-nerd Como descompactar um arquivo zip do Terminal? 2011-12-11 20:37:54 +0800 CST
  • Martin Hope
    TheXed Como instalo um arquivo .deb por meio da linha de comando? 2011-05-07 09:40:28 +0800 CST
  • Martin Hope
    Ivan Como listar todos os pacotes instalados 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    David Barry Como determino o tamanho total de um diretório (pasta) na linha de comando? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher "Os seguintes pacotes foram retidos:" Por que e como resolvo isso? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford Como os PPAs podem ser removidos? 2010-07-30 01:09:42 +0800 CST

Hot tag

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve