Question

I want to find a way preferable using command line to login into gmail and download an attachment in a windows environment (XP)

I have tried openssl s_client -crlf -connect imap.gmail.com:993 /openssl s_client -starttls smtp -connect smtp.gmail.com:587 to send mail, and it works But i need to receive mail, more specifically an attachment from my gmail

any advice, i'm stuck

Another way would be to install a POP3 client, but i dont want to use this method as the machine has very less RAM.

Was it helpful?

Solution

You won't be able to retrieve email attachments using basic command lines. You'll have to use a more advanced script language (ex : Python), with an Imap library to download messages, parse them, and eventually save attachments to files.

The reason is that the messages downloaded from your Imap server are formatted according to the MIME RFC. The Imap fetch command will allow you to download the MIME part representing your attachment, but it will be encoded (usually in base64). So, once downloaded, you'll have to decode the attachment, before saving it to a file. All steps that will be dealt with transparently by a proper IMAP library :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top