Use Curl to read your imap emails

You can use the bash command “curl” to read your imap emails like this:

curl --url "imaps://" --user "username:password"

Note: your password will be visible on the command line, so don’t use this on a public server.

So it is actually better to create a file, for instance called secret, then write your password in it, and protect it with:

chmod 400 secret

Then you can use this command instead:

curl --url 'imaps://' --user 'username:`cat secret`'

If there is a SSL certificate issue, you can also try (not recommended of course):
[code lang=”bash”]curl –insecure –url "imaps://" –user "username:password"[/code]
You need a newer version of curl, because version before 7.29 have limited imap support.

In order to upgrade curl on a Centos system, you can:

Create a new file /etc/yum.repos.d/city-fan.repo

Then paste the following contents:

name=City Fan Repo


yum update curl

You can very finally the version of curl:

curl --version

See also: