curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Access gmail with pycurl.

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 2 Jul 2021 00:11:42 -0400

On 6/29/2021 12:33 AM, Hongyi Zhao via curl-library wrote:
> On Tue, Jun 29, 2021 at 5:55 AM Daniel Stenberg<daniel_at_haxx.se> wrote:
>> On Sat, 26 Jun 2021, Hongyi Zhao via curl-library wrote:
>>
>>> I noticed that libcurl, hence pycurl supports IMAP and IMAPS, so I want to
>>> know if I can use it to retrieve/remove emails from my Gmail account?
>> Yes you can.
>>
>> Jay once wrote ShowGmailFolders.c for example:
>>
>> https://gist.github.com/jay/a43724c98220de85d020
> Thank you for this wonderful code snippet. But for quick testing, I
> try the following command based on the notes at
> <http://cweiske.de/tagebuch/curl-imap-noauth.htm>, but failed:
>
> $ curl -x socks5h://127.0.0.1:18888 -v -k --ssl
> imaps://imap.gmail.com:993 --user "username:passwd"
> * Trying 127.0.0.1:18888...
> * TCP_NODELAY set
> * SOCKS5 communication to imap.gmail.com:993
> * SOCKS5 connect to imap.gmail.com:993 (remotely resolved)
> * SOCKS5 request granted.
> * Connected to 127.0.0.1 (127.0.0.1) port 18888 (#0)
> * successfully set certificate verify locations:
> * CAfile: /etc/ssl/certs/ca-certificates.crt
> CApath: /etc/ssl/certs
> * TLSv1.3 (OUT), TLS handshake, Client hello (1):
> * OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to imap.gmail.com:993
> * Closing connection 0
> curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to
> imap.gmail.com:993


syscall error is probably your proxy. I can connect fine. Note you will
have to enable "less secure app access" [1] on your google account to
use the gmail username/password.  There is a way to do it with oauth2
instead. I don't think I've ever had to do that though and I don't think
we have an example for it.


[1]: https://myaccount.google.com/lesssecureapps





-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-07-02