I created a pop3 protocol connection to my Gmail server using OpenSSL on terminal, just for testing and learning purposes, I used retr {no} command to retrieve my email data, but the data is encoded in base64.
How can I decode my email data from base64 to text while retrieving the mail or after retrieving it?
Here are the commands I used to connect to the server and use pop3 protocol using Openssl:-
openssl s_client -connect pop.gmail.com:995 -quiet
user <USERNAME>
pass <PASSWORD>
NOTE :- The password should be the app password of your gmail
list
NOTE :- to list all the mails inside the server
retr 1
Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Content-Transfer-Encoding: base64
R29vZ2xlICANCjxodHRwczovL3d3dy5nb29nbGUuY29tL2FwcHNlcnZlL21rdC9wL0FGbnduS1Vx WkdQbUdFLTAxcVBRcDdkTUhHa3lZRnd3WnNBV3VZQjFmLTVWUHdhTXFQRGtTTjAwMDFKQVFCZ255 STI3YW9UbGswb2FHa2hIdTltMklIUGN0cDFrVGZTQzBNVUZnclVwSlNjN3lLNWE4RGRFZUVhbDdF VmZpTU5ObG91NXphOVEtZ3lQZ3VJWU9rd0FoT2sxdzZlUjVNZDBNYmlFMGc+DQoNCkhpIEFjaGlu dHlhLA0KDQpXZWxjb21lIHRvIEdvb2dsZS4gWW91ciBuZXcgYWNjb3VudCBjb21lcyB3aXRoIGFj Y2VzcyB0byBHb29nbGUgcHJvZHVjdHMsICANCmFwcHMgYW5kIHNlcnZpY2VzLg0KDQpIZXJlJ3Mg YSBmZXcgdGlwcyB0byBnZXQgeW91IHN0YXJ0ZWQuDQoNCkdvb2dsZSBHbyAgDQo8aHR0cHM6Ly93...
some of the encoded email
quit
NOTE :- to end the POP3 session
You have various options:
openssl base64 -d
perl -MMIME::Base64 -0777 -ne 'print decode_base64($_)'
python3 -c 'import sys, base64; sys.stdout.buffer.write(base64.b64decode(sys.stdin.buffer.read()))'
They all decode Base64 from standard input to standard output.