Talk smtp to gmail with openssl s_client

Here are the basic commands to talk smtp to gmail.

We will send email from to
The gmail password of is "my secret password".


To authenticate, we need our user/pass in base64 format:
base64("") = c2VuZGVyQGdtYWlsLmNvbQ0K
base64("my secret password") = bXkgc2VjcmV0IHBhc3N3b3Jk

To get the base64 encoded string, google "base64 online encoder" and click on any of the online encoder/decoders.

If you're using Gmail's two-step authentication

Go to and get a one-time password.

Ending the DATA of the email.

To end the DATA part, we need to press dot (".") and then Enter (which should send CRLF).

Important NOTE: I'm on a macbook, and the terminal client sends LF when I press enter. When I want to send CRLF, I press Ctrl+V, Enter. If you don't know what I'm talking about, after the dot (".") if it doesn't work with dot and Enter, press [dot, Ctrl+V, Enter].

The commands

We will use S_client which is like telnet, but supports SSL (encrypted telnet). You will need OpenSSL for that purpose.

[mihail@arch ~]# openssl s_client -connect -starttls smtp
[a lot of text will be printed - ssl info. For simplicity ignore it.]
auth login
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.7.0 Accepted
250 at your service
mail from:<>
250 2.1.0 OK dc8smxxxxwib.7 - gsmtp
rcpt to:<>
250 2.1.5 OK dc8smxxxxwib.7 - gsmtp
354 Go ahead dc8smxxxxwib.7 - gsmtp
subject:manual smtp with gmail
some text as the body of the email
more lines of text

250 2.0.0 OK 1414600919 dc8smxxxxwib.7 - gsmtp
221 2.0.0 closing connection dc8smxxxxwib.7 - gsmtp
[mihail@arch ~]#




If you want to use SSL 465, the command is:
#openssl s_client -connect -tls1

(here you need to start with HELO, and then AUTH LOGIN - I don't know why)


Also, some accounts fail with:

3073894076:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598:

I don't know why. It seems like it wants to fall back to ssl3.

FBI is on their way to your house (a south-african scheme to steal money)

I am selling my old motorcycle and it is listed on an online auctioning site. Following is my communication with a south-african guy trying to steal some money from me. I continued the communication with him as far as possible, because I was interested how these things go. My info is anonymised, his info is not, so that google may cache his name name and contact info. The fun part is in bold.

--- I receive a text from +1 (717) 826 0150:
Is ur bike for sales?if yes get back to me via email (

--- I reply to the email:
My bike is for sale. You sent me a text. Wanna buy it?

--- him:
I am really interested in the immediate purchase of your merchandise and i will like to know how long have you owned it??  what's your best price for it and when last was it serviced?

--- me:
Now what?

--- him:
Thank you for getting back to me. Can you assure me that it's in good state and that i will not be disappointed with it.I'm ready to pay your asking price and to be honest, i wanted to buy this for my Son, but the issue is i am an oceanographer and i do have a contract to go for which starts tomorrow and am leaving any moment from now.The contract is strictly no call due to the lack of reception on the sea area. But I'm able to access email anytime as we will make use of laptop so my only quickest payment option is PayPal as i can send money via PayPal anytime.Since I'm requesting this transaction to be done via PayPal, i will be responsible for all the paypal charges on this transaction and if you don't have an account with paypal, its pretty easy, safe and secured to open one. Just log on to I hope we can make the purchase as fast as possible? I have a mover that will come for it once payment clears and they will take care of very necessary paper for me. So i look forward to hear from you soon. will like to see more pics.
I need the address where the agent will meet you and your PayPal Full name and email address so i can send the money now.

--- me: (newly created paypal account)
paypal account:

--- him:
i have just completed the payment via PayPal. A total of €1,650.00 EUR was sent,€1,100.00 EUR for the bike and the extra €500.00 EUR for the shipping charges and €50.00 EUR for the western union charges am sure you notice that,which you will be sending the €500.00 EUR to the address below via western union.I will advice you to check your inbox or spam mail of junk am sure you will find the Paypal confirmation email in one of those box.

Name : D A V I D - O L A G U N J U
Address: 65 Celliers street,
City: Pretoria
Post Code: 0002
Country: South Africa.

The shipper would be coming around to your area to have the bike picked up once you have sent the shipping charges fee to them,as i need you to send me your home address for the pickup and let me know what time you want them to come for the pick up.

I will be waiting to hear from you once the money has been sent to the shipper.

--- him again:
i receive a message from paypal stating that a legal action will be take against you since you refuse play your role in the transaction going on between me and you and now i don't even know what to do because am confuse.So please lets try and sort this out try as much as possible to the money and settle the shipper because i wont like paypal taking a brutal action against you... Wish to read from you soon.

--- me:
Oh my god. What should i do to stop that? I have a lot of money in paypal and i don't want it blocked.

--- him:
Hi, it's up to you as well to act fast as I'd already made the full payment through PayPal. There is nothing I could do from my side to influence PayPal rules. It's better you act according to PayPal request or I mail PayPal to suspend the transaction.I look forward to hear from you soon...

--- me:
I already sent you the money. I am at work now and the receipt is at home. tomorrow I am going to scan it, because I don't have a scanner at home.

Please don't suspend the transaction.

--- him:
You can send the following details to me so that i can forward it to PayPal management..

(1) Sender's Name;
(2) Receiver's Name;
(3) MTCN (Money Transfer Control Number);
(4) Amount Sent;

Get back to me asap..

--- him:
Stephen De-Guerre
1650 EURO

You are ask to send the scan receipt to me,so that we can confirm the transaction.

--- me:
I can do that tomorrow evening.

--- him:
Send it now...........Cause FBI is on their way to your house.

--- me:

--- him:
Send it when you get home...

--- me:
PROMISE ME YOU WILL STOP THE FBI. I don't have a scanner at home. I can scan it at work only. Only if the scanner is free and nobody is in the office. I will wait after everyone leaves. So 5pm tomorrow

--- him:
I will ask PayPal management to stop the FBI....So get back to me with the scan receipt by 5pm tomorrow..

--- me:
Thank you, thank you, thank you, thank you. Why are you being so mean?

--- He stopped the communication ---