You are not logged in.

#1 Yesterday 11:22:28

jpka
Member
Registered: 2024-12-04
Posts: 8

"You have mail" check via command line

Hello.

I am "just" need to know if I am have new messages at remote pop3 server, with results (return values set) of: There is mail, No mail, and Error occured. (Via return code, or via temp file content)
Like `xfce4-mailwatch-plugin` provides, but, with command line.
No need to read or send mails via CLI. It should be one-command, non interactive, using standard tool. It can be not fast, but preferably with no more than one minute timeout, should terminate with error then.
I've noticed that there is no package provides `mail` command; anyway I have no idea if `mail` is suitable.
What I found working so far, is interactive one, like

    openssl s_client -quiet -connect remote_ip:110 -starttls pop3
    ...
    +OK Dovecot ready.
    USER me
    +OK
    PASS me_again
    +OK Logged in.
    LIST
    +OK 1 messages:
    1 154796
    .
    QUIT
    +OK Logging out

While it probably can be converted to automated one using bash script, i am expect that it is solved already with some CLI tool(s) comes with Archlinux. Please suggest me some.
There is a lot of general search results how to send mails, but, just a few for receive, and nothing for just check, I am found so far.

Thanks!

P.S. I am sorry if this general section is incorrect place for ask about software suggestion; I can't find more particular suggestions section at forums here at Archlinux.

Offline

#2 Yesterday 12:55:40

cryptearth
Member
Registered: 2024-02-03
Posts: 2,305

Re: "You have mail" check via command line

first: i would use imap instead of pop - because of IDLE command: with imap you connect once, issue an idle command and have the server inform you when it got new mail; with pop you have to keep polling - that's something from the past

as for the tool itself: i would go for something on my own - the mail procols, namely smtp, imap4 and pop3, are so old and well established there're well tested libs out there for pretty much any lamguage - using such lib along with imap idle and some notification can be done in 20-30 lines, nothin special

or: just get a regular mail client like thunderbird

Offline

#3 Yesterday 15:06:56

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,615

Re: "You have mail" check via command line

Yes is and has - you're also almost there  and only have to feed some input into openssl s_client and read the output (technically you need this to be interactive but if you don't tell anyone: you can just stray in some tactical "sleep" to wait for the server's response wink)

Otherwise there's eg https://perldoc.perl.org/Net::POP3 - as
Then there's https://archlinux.org/packages/extra/x86_64/mpop/

For imap there'd eg. be https://archlinux.org/packages/extra/x8 … mapnotify/ but how the fuck can that be 9MB??
=> See eg https://metacpan.org/release/PLOBBES/Ma … es/idle.pl

or: just get a regular mail client like thunderbird

https://archlinux.org/packages/extra/x86_64/mutt/ is smaller than that go monstrosity (and most of that is the documentation), works on the console and can fire random scripts when new mail arrives.
It also supports imap and pop3 and you get to look at the mail and delete the spam as well smile

Oh, and then there's of course https://man.archlinux.org/man/mail.1#e

pacman -F mail # or search the database for "nail" to find a dad joke

Online

Board footer

Powered by FluxBB